Laptop keyboards aren't the most reliable of things, usually one of the first things to go on a laptop.
Take the B and N keys apart, and see if there's any debris/obvious damage with the contact underneath. If it's all clean and still doesn't function after that, see if you're able to check the ribbon cable and see if it's loose, as sometimes these can wiggle out of their slot and cause issues like that.
Worst case the keyboard is just dying and will need to be replaced. Depending on your laptops age and maker, this can either be an easy process, or an extremely massive pain in the ass. A lot of modern laptop keyboards these days are simply built into the top half of the chassis, for instance, and would require that whole top half to be removed and replaced, and replacement parts for those are usually more expensive than just a direct keyboard replacement.