V + 고 말다 shows that after doing one action, the final outcome was a contrasting (and perhaps negative) one. It roughly translates to ‘I ended up Ving’, ‘in the end I V-ed’ or ‘finally I V-ed’. 결국 (also ‘in the end’) can be added for emphasis:
밤을 새야하는데 잠에 들고 말았어요.
I tried to stay up all night but eventually I fell asleep.
숙제를 끝내려고 했지만 포기하고 말았어요.
I tried to finish my homework but I eventually gave up.
차가 비쌌지만 결국 사고 말았어요.
The car was expensive but in the end I bought it.
버스는 덥고 복잡해서 집까지 걸어가고 말았어요.
The bus was so hot and crowded so I ended up walking home.
시험을 봤는데 준비를 안 해서 결국 떨어지고 말았어요.
I did the test but I didn’t prepare so I ended up failing.