If for some reason your car forgets the key's remote id then it will need to be resynced. Below are the steps to resync the key to the car. The procedure below is scanned directly from the BMW owner's manual. BMW is not trying to keep this a secret so they can make money doing it for you. It says for New transmitters, but, it works for old transmitters as well. The procedure is the same for the newer diamond shape keys, just remember that Button 1 is the unlock button (the button closest to the key blade) and Button 2 is the lock button (center button with the BMW logo). Have all the keys with you when doing the resync procedure. Keys not synced will be forgotten by the car and the remote will no longer work! This procedure is for the remote keyless entry only and has NOTHING to do with the ability to start the engine. It will not fix keys that do not start the engine and won't mess up a key so that it won't start the engine. Old Key/New Key information.
https://www.bmwgm5.com/Key_Recode.htm