Switching only possible when the engine is off

Hello together I hope that I can be helped here. And this is about my MX5 NB 1998 My problem: Everything went Tip Top up to that day when I started my NB and it rolled forwards despite the kicked clutch… then I realized that the gears did not go in anymore. My first thought engine from engine again and it still did nothing:'( Then after eternal back and forth I found the gears as soon as I turned off the engine without any problem e went in. What could that be?? I’m already thinking about selling him what I really want to avoid… What you might still know: My friend managed to drive the car to me, however, he said it was really tedious.. I am grateful for every advice.