One problem I have seen with Deraileur gears after say a puncture, is caused by the owner simply not placing the wheel exactly where it was both in position front to back, and side to side.
The tyre must run exactly in the middle between the chain stays IMHO!
I pull the axle back on the RH side, till the RH nut is back exactly where it was.
Then I slightly tighten the gear side (RH) nut, which pushes on my bike, the tyre towards the gear side chain stay.
I then gently pull the non gear side part of the exposed axle towards the rear and slightly to the right, tightening the nut when the tyre is as near as exactly in the middle, and LH side nut is where it was previously.
Then I tighten fully both nuts.
If you have panniers, it might be a good idea to remove them first!
This works for me, but a buddy of mine, uses a completely different setup, that works well for him, but to my mind, it was difficult to follow and it still ended up looking just the same! (I also had no interest in a different procedure, if I am being honest!)
Then, when I need to adjust my gears, which is very seldom thankfully, I always go and look at YouTube, which has a mountain of helpful videos. Here are some for you to pick through:-
I hope this helps as the error you have must be most annoying for you!
To not have to go through this procedure, I slip the tube out with the wheel still mounted, but I do not remove the wheel, its a bit fiddly, but not as fiddly as you are experiencing IMHO!
Possibly on some bikes, it may simply not be the best option to do this!
Furthermore, the cassette on my previous bike, would start dropping the chain after a few years, but only while riding, and eventually I unwillingly replaced it and the problem was gone completely! Cheap fix!!
It did not look worn (rear hub motor), but it must have been in some way....
If it happens say only on the higher gears, you may have the wrong tension on the chain tensioner, but "parking" in a lower gear may work as a temporary fix, as might lubing the chain....
Regards and the best of luck.
Andy