This is how I suspect the circuit is wired, but you'll have to investigate to be sure.
![enter image description here](https://i.stack.imgur.com/r5PQ3.jpg)
In the fixture junction box:
White = Grounded (neutral) conductor.
Black = Ungrounded (hot) conductor.
Red = Switched ungrounded (hot) conductor.
The circuit may be wired this way because it continues on to feed other rooms, or simply because the switch is a "smart" switch that requires a grounded (neutral) conductor.
You'll learn a bit more about the circuit, when you open up the switch box and take a look inside. If you're still not sure what's going on, you'll have to probe the wires to gain a better understanding. If at any point you don't feel comfortable, or you're in over your head. Don't hesitate to contact a local license Electrician.
What is probably happening here is you have power to the light on one black, another black to the switch, and a return path along the whites. That is, the switch is AFTER the light.
This is generally unsafe as the light is still energized, even when the switch is off, and should be fixed regardless.
The first thing I'd do is beg/borrow/steel a non-contact voltage detector.
With everything still attached, switch the light off. If I'm right, the detector would read hot on BOTH black wires, and the whites will be un-energized. Flip the switch and the whites should be energized as well.
If this is indeed the situation, the fix is relatively easy. Turn the power off! Remove the existing light.
Figure out which pair is wired to the switch. The easiest way is to use a meter in resistance mode. Find the black-white pair that shows low resistance when the switch is on, and open circuit when switched off. Mark the white wire with a loop of electrical tape. This will be the switched hot.
Now wire the blacks together with an appropriate wire nut, and make sure it's a secure connection. You should not be able to see any copper.
Wire the switched hot (the white wire marked with tape) to the black wire of the new fixture. Wire the remaining white to the white wire of the fixture. Make sure you've grounded the fixture according to the manufacturers instructions.
Mount the fixture, and turn the power back on.
Best Answer
Electricity doesn't care about color. But electricians (both pros and amateurs) do.
The color is meant to inform both you and any future worker which wires are hot (usually black or red, but occasionally other colors, such as blue), neutral (white or sometimes grey), ground (bare, green or green/yellow striped). If it is not bare, white or green, it is potentially hot.
Code lets you use wire with a different color insulation than the standard if you mark it permanently with the correct color, such as a piece of colored electrical tape, heat shrink tubing or with paint. That way, when you return to the fixture/switch/outlet three years from now, even if you cannot remember what you did, the color of the wires will guide you. And for someone else working on your circuit, it is essential.
Code in all states that I know of in the US require correctly marked wire (either the original jacket or a subsequent marking). Wrong color is a violation. I do not specifically know Michigan code (and it probably varies by local jurisdiction), but it almost certainly follows the standard code when it comes to wiring colors.
On your followup question, it was very common to use 14/2 or 12/2 wire to run a switch loop (a hot line to the switch and a switched hot returning from the switch). The code required that the white wire be marked black (or red) to show it was hot.
Code now requires that all new switches have a neutral, so the old two wire switch loop is not allowed, even if you are using a dumb switch that doesn't need a neutral (some future switch might). So if you are running a new wire, you might as well use 14/3, use the black and red for the switch and leave the white capped in the switch box. You should attach the white at the fixture so that in any subsequent wiring project it will already be properly connected.