A very basic law in electrical engineering is ohm law which says:
V = I * R
V : is the voltage of the battery.
I : is the current that flow in the wires, the resistor, and the led.
R : is the total resistance of the circuit.
Let's calculate it first then understand why the resistor is at the positive terminal:
You are using 2 * AA battery. Each AA battery has 1.5 volts. It means the total voltage is 3 volts because you are using two batteries.
V = 3 volts
I assume that you use 100 ohm resistor.
The current that should flow in the circuit = 3 / 100 = 0.03 ampere
Now, The resistors control the current of the circuit and the amount of current should be 0.03 ampere. In Which direction?
The real electrons moves from the negative terminal to positive terminal. But that does not mean we should put the resistor at the negative terminal. Current pass or flow inside the wire and If you want to put something to interrupt it or make it slow down, you can put it in any place in series with the wire and it will interrupt the current. Think of a water pipe, If you want to slow the speed of water that pass through the pipe, you can put a rock (or something) inside the water pipe (No matter the place is) and the water will be interrupted.
If you are confused about the direction of flow of current: The real electrons moves from negative to positive. and We can imagine that there is positive charges movies from positive to negative, the imaginary positive charges move in the opposite direction of the negative charges. Now, I think it make sense. Why we imagine the direction of positive charges? because it is easier when you deal with complicated circuits and Circuits that have a lot of resistors, leds, capacitors and so on.
The answer of your second question "how a resistor would prevent a battery from shorting out?" is Ohms law.
The voltage of the battery does NOT vary. and the led have low resistance. so the current will be very high. High currents generate heat quickly and may damage leds and other similar components.
Now we have to solutions, to decrease the voltage of the battery (it is impossible in many cases) and the other solution is to increase the resistance which what you have done.
The equation of ohm's law is described in the following picture in a funny way: