If you live in an apartment building why would the power occasionally go out in only one or two rooms during a storm but then eventually come back on on its own?

The distribution lines that supply the power have fuses or cutouts that are before the stepdown transformer that feeds the apartment. The fuse or cut out can blow one at a time,sometimes only one of the two will only be affected. They also are designed to reset automaticaly after a period of time. This is why the power will suddenly come back on. your power in the apartment is split between the two distribution lines , to balance the load.