It probably just needs syncing to the car. If the battery has been flat or disconnected it will lose sync so is normal. If it is locked with the key, it can be unlocked with the key so the immobiliser will still be on but being turned off when you unlock. It has probably had a cheapo replacement case fitted and not glued together properly but if the LED flashes, that is a good sign and suggests it is working.
To sync make sure all doors, bonnet and tailgate are closed, put the key in the door lock. Turn to lock and hold there, while holding the key turned press and hold the lock button on the fob until the LED starts to flash faster (about 3 seconds). Release the fob button then turn the key back to centre. Then turn to unlock, hold, press and hold the unlock key on the fob until it flashes faster then release. Turn the key back to centre and try pressing a fob button, that should have synced it so it will now work.
Assuming it does and you are in the UK, take your V5 and some form of ID into a LR main dealer and ask them to provide you with the EKA code. They should give you a printout with things like radio code, EKA, lockset bar code, build date, etc. free of charge. Go to your local Timsons and ask them to cut you a key blade (you'll need to tell them it is a BMW blank) so you'll have a spare that you can use while you send your fob to Jon here https://www.ebay.co.uk/itm/265688990980 to be refurbished. Even if the sync doesn't work, you'll still be able to use your cut blade while Jon works his magic on your existing fob.