Why did my game end in a draw?

OK but when exactly does this rule kick in? I'm new to chess and don´t know all the rules but I would really like to understand this one because I don´t want the same to happen again!

it is a draw because the same position was repeated 3 times, after 54. ..kg6, 56. ..kg6, and 58. ..kg6

Ah OK I heared about this rule. But I thought it was more like three moves can not be the same. So if the exact same position shows up three times in the same game, it will always be a draw? And it dosn´t matter what has happened inbetween those times when the position showed up?

Ah OK I heared about this rule. But I thought it was more like three moves can not be the same. So if the exact same position shows up three times in the same game, it will always be a draw? And it dosn´t matter what has happened inbetween those times when the position showed up?
yes, it doesn't matter if anything has happened in between. though usually the three repeated positions are in three consecutive moves

Ah OK I heared about this rule. But I thought it was more like three moves can not be the same. So if the exact same position shows up three times in the same game, it will always be a draw? And it dosn´t matter what has happened inbetween those times when the position showed up?
It's a bit more complicated than that. Yes, the position has to be repeated 3 times, and that can be at any point in the game. But also, all 3 times it must be the same player to move and both players must have the same possible moves. For example, if White can still castle the first time the position appears but then moves his K to d1 and back to e1, the new position has to be repeated 3 times for the rule to be invoked. The reason is that White could castle the first time the position appeared but can't castle the next time.

Ah OK I heared about this rule. But I thought it was more like three moves can not be the same. So if the exact same position shows up three times in the same game, it will always be a draw? And it dosn´t matter what has happened inbetween those times when the position showed up?
It's a bit more complicated than that. Yes, the position has to be repeated 3 times, and that can be at any point in the game. But also, all 3 times it must be the same player to move and both players must have the same possible moves. For example, if White can still castle the first time the position appears but then moves his K to d1 and back to e1, the new position has to be repeated 3 times for the rule to be invoked. The reason is that White could castle the first time the position appeared but can't castle the next time.
That's interesting I did not know that fact
This is very helpful, the same thing happened to me yesterday. I thought the same moves have to be repeated, not the same end position attained. Good to have this clarification and avoid repetition draws unless desired.

Another question from a beginer (on chess but also this forum). How do I post a chessboard with a game like the post above?

Another question from a beginer (on chess but also this forum). How do I post a chessboard with a game like the post above?
in the top-left, you should see an icon that says "insert chess game or diagram"

Go to the game you want to post. Click on the download icon.
In the PGN field choose Select All and then Copy.
Come back to the forum you want to post a game in. Click on the board icon.
Click on Load from PGN and then Paste.
Click on Load.

Sometimes it does not work to copy the png file from chess.com analysis. I use free version which I think means I can not save the file (?). but sometimes it works to just mark the moves and copy-paste but about half of the times it will not copy for some reason. When I paste its just "0" or "1". Sometimes it works to copy half of the moves. Or maybe only a few. Or almost every move. But can´t see any logic, a long game can be OK to copy but a short no, or vice verse. And when I try to paste it doesn´t work it doesn´t matter where I try paste it (Lichess, Word, Excel or whatever). Anyone else experience the same problem?
Can someone please explain why this game ended in a draw? This is the game (hope it works to copy the moves like this):
1. e4 e5 2. Nf3 Nf6 3. d4 exd4 4. Qxd4 Nc6 5. Qe3 Bc5 6. Qxc5 Nxe4 7. Qf5 d5 8. Qf4 O-O 9. Be3 Re8 10. Nc3 Nf6 11. O-O-O a6 12. h3 Be6 13. Ng5 h6 14. Nxe6 fxe6 15. g4 e5 16. Qf5 d4 17. Bc4+ Kf8 18. Ne4 b5 19. Be6 Qe7 20. Nxf6 gxf6 21. Bd7 Red8 22. Bxc6 Rab8 23. Bxh6+ Kf7 24. Qh5+ Ke6 25. Qg6 Rg8 26. Qf5+ Kd6 27. Qe4 Kc5 28. Qd5+ Kb6 29. c3 Rbd8 30. Qe4 Rh8 31. Bd2 Qc5 32. Bb7 dxc3 33. Bxc3 Rxd1+ 34. Rxd1 c6 35. Rd7 b4 36. Qxb4+ Qxb4 37. Bxb4 c5 38. Bd2 Rxh3 39. g5 fxg5 40. Bxg5 Rf3 41. Bxf3 Kb5 42. Rb7+ Kc4 43. Ra7 Kb5 44. Bf6 Kb6 45. Rh7 c4 46. Bxe5 Kc5 47. Rh5 Kb4 48. Be2 a5 49. Rh3 a4 50. a3+ Kc5 51. f4 Kd5 52. Bh8 Ke4 53. Rh4 Kf5 54. Bxc4 Kg6 55. Bd3+ Kf7 56. Bc4+ Kg6 57. Rg4+ Kf5 58. Rh4 Kg6