I'm replacing a single 2-way ceiling light with recessed lighting, and discovered what I think is a switch loop when I pulled the ceiling light out. The confusing part (to me) is that the ceiling light had two 14-2 romex going to it, and one 14-3. All the diagrams I've looked up online show that there should be two 14-3s. What's going on?
You have the power supply coming in from the ceiling (i.e. right side 14-2) and being sent down to the switch or switches (i.e. left side 14-2). What's then sent back to the light or ceiling box is coming through the 14-3 and would be or indicates there was a either ceiling fan here previously (using the wrong type of electrical box) or that it was wired for one (ceiling fan box would've or should've replaced the standard box).
In a ceiling fan setup, the 14-3's black would be powering the fan and the red would power the ceiling fan's light (based on picture below). I'm hesitant to include a picture, since I couldn't find your exact setup and add to the confusion. But, the picture below is similar to your situation, however they skipped the 2nd 14-2 and just used the white to feed power to the switches...I agree much more with your setup.
I would expect there to be a capped black at the switch box and would like to see that 1 black disconnected and capped also in the ceiling box, if not being used. Though, that 3rd black could be going off to power something else with the switch box also being used as a junction box. Sorry, I can't be definitive without more pictures.
All the blacks and all the whites are tied together meaning you have 2 hot wires leaving the box and two neutral wires leaving the box. The hallway light may be on a 3 way lighting circuit but not all of these wires make up that connection. Most likely you have a 14/2 coming from panel which you can think of as the main body of a tree.. The 14/3 and second 14/2 arelike the branches of the tree. The 14/3 branches out from the tree and extends to a box that contains the switch that controls the hallway light. The black and white from the 14/3 tree branch then stem out making twigs that lead to other switches and lights as well as the second 3 way switch for the hall way light... The other 14/2 in the photo is another tree branch which extends to say the light switches in all the bedrooms off of the hall way or the outside porch light.