A confusing situation-is this stalemate? Today I played a game, and it was my turn in the endgame.

I had only one pawn, which is blocked, and my king left. But my king could move only to a single square legally, as it would otherwise be in check. However, on the next move of mine, I had to put my king back on the square that it came from. I had to repeat these moves 8 or 9 times, with no another moves available. My king was stuck within those 2 squares.

I was confused, and I still am. Eventually, my opponent promoted a pawn to a queen, and afterward, in 2-3 moves, he checkmated me.

Can anyone explain this type of situation? Is it stalemate, or something else?
A stalemate is when, during your turn, you cannot make any legal move. The game then stops as a draw.

As long as you can make a legal move, with any piece, it's not a stalemate. Therefore the situation that you have described is not stalemate, as you had legal moves every single turn.

There isn’t really a name for the situation that you are in, but it is best called a repetition for simplicity’s sake.

Now, if your opponent also made the same moves as well every single time, and it were a tournament it would be called a threefold repetition and you could claim a draw. But only you are repeating your moves.