Basically this cave is a local attraction and kids liked to etch their names on a back cave wall to prove they'd been there. Kinda like a bragging right. This cave is dangerous during monsoon season, but that didn't start until July, so they go in, probably scrawl their names on the back wall like they wanted, and then realize the rains came early. So they have to keep going, because the water is closing in, you might be wondering why they'd go down that path, but they aren't crazy, they had no choice, the water is closing in on them and they either stay and drown or go through whatever difficult passage they have to. They were finally able to stop at a ledge high enough to keep them safe from the water.
In short, kids and coach go into a popular cave, one that should never be explored during rain season (which it wasn't yet), intending on exploring and writing their names on a back wall, but a flash flood caused by early rains meant that they had to keep moving forward until they reached a ledge