The power (from the breaker) is likely at the light fixture. When you hook black to black and white to white, the light is powered directly from the breaker. In this configuration, when you flip the switch on
you create a short through the switch.
What you need to do is hook it up like this.
Notice the white wire that runs between the switch and the light has a black stripe on it (in above image), that lets anybody that works on this light in the future know that the wire is switched. You can mark the wire using a bit of electrical tape, or a marker.
Figuring out which wires come from the breaker, and which go to the switch will require some tools. First Turn off the breaker, and verify the power is off using a non-contact voltage tester. Now pick one set of wires to work with first (one black and one white from the same cable). Turn the switch to the on
position, and use a multimeter to check continuity between the two wires. If the wires are connected (low resistance), these are the switched wires. If not (infinite resistance), check the other set of wires. If neither pair pass the test, contact an electrician.
If at any time you don't feel comfortable doing this work, or you don't have the proper tools to complete the task. Contact a local licensed electrician.
If the old fixture worked, at least one of the white wires is hot.
The easiest way to check which is hot is to use a non-contact tester. If the fixture is already removed, leave the two wires bundled together with a wire nut over the end. Put a wire nut on the single white wire. Turn the breaker back on. Only one of those should register on tester. That is the hot side. The other should not register. That is the neutral.
Once you know which wire is hot, mark it with black tape or a permanent marker.
If the the fixture is still attached, you can do the same thing with the fixture hanging down. Once you know what is what, turn the breaker back off before wiring.
The black wire goes to the hot wire, the white to the neutral. The ground wire should be attached to a green or bare wire if there is one in the box, or to the box itself if it is metal. If not, just cap it.
Best Answer
Wire nut two blacks together. Push them back in the box. Attach new fixture black to red. Connect all whites together. Connect all grounds together.