It was an old singleplayer 2D medieval game that I played 10 years ago. I would say it's some mix of Action Rougelike and Castle Defense. You start at the castle, which on the beginning has no walls or towers, and through fighting enemies you get gold with which you upgrade your castle and your own weapons and armor. You can later even recruit your own soldiers to fight for you. The enemies that you fight against are trying to raid your castle by destroying the walls and entering the castle to kill you.
I played it on some free sites with all kinds of games, like Miniclip, Kongregate, Crazy Games, etc. But I can't remember which one specifically, and I can't find it on those pages anymore.
I would be very happy if I could find it again!
Source: https://www.reddit.com/r/oldgames/comments/ulo89w/what_was_that_game_called/