The transformer can't power a thermostat unless it is a five wire configuration where a common wire has been brought from the transformer and connected to a "c" lug. In this case batteries would be optional and useless. Setting are stored in non volatile memory that needs no power.
In a normal 4 wire config, the batteries run the thermostat. Red is power and every other wire an extension of that as the thermostat calls for it. Below is from a honeywell non programmable thermostat manual.
1. Replace the batteries as soon as Replace
Battery flashes in the display. The Replace Battery
indicator flashes in the display two months before
the batteries run down completely.
2. Always use fresh AAA alkaline batteries. Nonalkaline
batteries do not last as long and can leak,
causing damage to the thermostat.
3. Although the thermostat has a Replace Battery
indicator, replace the batteries once per year to
prevent the thermostat and heating/cooling system
from shutting down due to a lack of battery power.
NOTE: Replacing the batteries once a year also helps
prevent battery leakage that can damage the
thermostat.
4. As a precaution, replace the batteries when leaving
your home for more than a month to prevent your
heating/cooling system from shutting down if the
batteries run down completely.