The rules for panelboard locations are scattered throughout the code. There are working space requirements, dedicated space requirements, panelboard requirements in section 408, but the one section relevant to your question is in article 240 restricting locations for overcurrent devices. 240.24(D) Not in Vicinity of Easily Ignitible Material, and 240.24(E) Not Located in Bathrooms. The easily ignited materials rule keeps them out of clothes closets, but that could apply to portions of a laundry room (e.g. next to a clothes chute dump) or clothes/towel storage area.
It is also important to know the NEC definition of a bathroom: An area including a basin with one or more of the following: a toilet, a urinal, a tub, a shower, a bidet, or similar plumbing fixtures. So a bathroom must have a sink and something else. If it is a toilet only room, or a tub only room with no sink, or a sink only room, it isn't a bathroom.
Finally, panelboards don't require a dedicated room, but they require dedicated space. This is just a vertical section directly above and below the panelboard which is reserved for wiring only - no pipes or ducts or things from other systems can be in that area. And they require working space - the area in front of it must be clear for 30" wide and 36" deep. A door can swing into this area, but the wall space must be >=30", and no equipment can be placed in that clear working space.