The collision detection will move the object back to it's last position before the collision occured so that it is not colliding. Collisions like this more or less stop things from going through one another. If the objects are moving slow enough the last position shouldn't be too far from the object it collided with.