It is not advisable to turn the switch OFF while the engine is running but it is OK to go from "1" to "BOTH" to "2".
If you are charging
both and only one is getting charged it is probably an indication that the battery is bad.
Normally you would dedicate one battery to starting and the other to house loads but original boat wiring
frequently puts everything on the one switch so you have to do everything manually. That means select the starting battery to start, then when running put the switch on BOTH for about 10 minutes to replace the charge in the starting battery, then go to 2 so the starting battery is isolated and saved.
Then when you anchor
out you are running down 2 for house loads and saving 1 for startng in the morning.
If you don't trust your memory to do all the switching many people install a Combiner (google battery combiner, Defender has them for about $65) It will do all the switching automatically and doesn't have a voltage drop like an isolator.