One possibility is a loose wire in the circuit that supplies those bedrooms.
In an older house, it's not uncommon for both the lights & outlets in a bedroom to all be on a single circuit, and to share that circuit with a neighboring bedroom. Are these 2 bedrooms next to each other?
This is something that should be fixed, because if it goes out then comes back on again, the wire is loose enough that something (people walking heavily down the hall, bumping into the wall, plugging/unplugging something from an outlet with a loose connection, or even just temperature changes) is causing it to connect or disconnect. A loose connection like that will heat up, and could possibly start a fire.
To find the problem, you need to trace the wiring from the main breaker box out toward these bedrooms, or trace backwards from the bedrooms toward the breaker box. In either case, look for a spot where it switches between live (powered) and dead (unpowered) circuit. Then look around at that point for a loose connection. (Backstab terminals on receptacles are notorious for becoming loose after a few years.) And sometimes the loose connection will actually be in the previous box.
It's possible for this to be a broken wire in a cable inside the wall, but that's pretty unlikely (especially as it goes on & off at times). It's much more likely to be a loose connection somewhere. And that's easy to fix; it's finding where it is hard (or, at least, that takes time).
But this is a situation that should be fixed! Until then, you should consider finding the circuit breaker that powers these 2 rooms, and leaving it turned off for now. Sounds like these rooms aren't used that much anyway?