Charging two batteries with one solar panel
You can charge two batteries together, you can charge them either in series or in parallel. Looks to me you'll be charging them in series because that's the way they'll be connected.

But I'd suggest you use a proper charger circuit to do it. You haven't said what kind of batteries they are and that matters as to how they should be charged.  The simplest charger I ever saw was a resistor connected to a NiCd battery! All that did was limit the current flowing into the battery so it charged up slowly. But not recommended! You need a way to detect when the battery is full and stop charging it (as overcharging damages the battery).

The other issue you have got is your 24 volt panel. It will may only produce 24 volts when in maximum bright sunshine. If you've got a charger circuit that will use some volts, which generally means the output of the charger is going to be less than 24 volts, which means it probably won't be able to charge the battery fully. (As the battery charges up, typically the voltage increases. You've got 2x 12 volt battery, for a single battery (lead acid type), the terminal voltage can go up up higher than 12V, 12.5, 12.8, and the charger voltage will go up as higher as 13.8V in order to charge it.  So chances are you are are not going to be able to charge a 24V battery (2x12v) fully with a 24 volt panel and a charging circuit, unless you start using sophisticated chargers, DC converters which can step up the voltage.

And you might want to stick a diode in series with the panel and what it's feeding power to (the charger, the batteries), as you may find (depends on the panel) in low levels of sunlight, the batteries discharging back through the panel and draining them. Particularly true if you leave the batteries permanently connected to the panel.

Look around for 24Volt solar charge controllers, see whether something like that might be suitable.