Assume basic residential wiring is similar across the USA. Should the bath wall light above the vanity have an electrical box attached to the drywall or stud?
Some fixtures are UL listed to serve as the junction box for their supply connections. That appears to be the case for the photo posted. Using the fixture as splice point for other cables for the bathroom would not be proper.
I see nothing that the original electrician did wrong.