Someone please explain the end of JSA: Joint Security Area

I picked this movie up on a whim and I have to say I greatly enjoyed it, however even on rewatching the climatic scene in the hut I can’t quite picture exactly what happened. Did the southern sergeant really attempt to shoot the northern sergeant (sorry I can’t recall their names, its been a while since I saw the movie), if so why did they go to such lengths to protect each other afterwards?

In addition what was the significance of the very last scene where it zooms in behind the northern sergeant doing ceremonial duties at the border and appears to show the southern sergeant and his friend in north korean uniform?

Thanks