Now, this isn't confirmed, but as far as I can tell, they aren't actually enemies.
The control two different dimensions; Space and Time, and are in a way opposites to each other. This is basically done with every single game where there are two legendary Pokemon that are two sides of one coin. This doesn't mean that they are enemies in any sense. One could argue that it's the whole "Space Vs Time" battle, but that doesn't really make sense, since they should live in harmony with each other.
Now for the movie, yes, the did fight. But there was also an explanation to why they fought two movies later;
Recently, Arceus has begun to awaken which has caused ripples in the space-time continuum. As a result, the Temporal and Spatial Worlds intersected with each other. Both Dialga and Palkia believed that the other had attempted to invade their territory which caused the battle that almost destroyed Alamos Town.
This movie also explains the whole thing with Giratina, in case you were interested.