Hello, and welcome to HF! How long have you been riding?
Losing stirrups is something that we've all been through and nothing to be worried about. Yes, it will improve, especially with time.
But, as you have already said, losing your stirrups often has to do with tension in the knees, leg, seat, etc. In the posting trot, it is also a sign of using the wrong muscles to post.
In your photo, your left leg is very toe-out, meaning that you are using the muscles at the back of your thigh instead of the inner thigh to post. However, perhaps this is just the photo or a transient change in your position, because your lower leg position in your profile pic is much better.
Either way, believe it or not, what I would recommend is that you do more stirrupless work. Do you do any at all? Of course, this also depends on how long you have been riding and your ability to balance, so you should discuss whether you are ready with your instructor. But, stirrupless work (even at just a walk) makes us use a longer leg and our inner thigh muscles, which give us stability in the saddle. With that added stability and longer leg, you will develop muscle memory that will improve your leg position when you pick up your stirrups again.
I rode at a New England college, and our team practices always began with 15 minutes or so of warm-up without stirrups. However, if your horse is a bit more active at the start of class, this is something you can do during cool-down.
You should also get into the habit of stretching your legs (touch those toes!) before every ride. I am surprised at how few riders stretch, as it is an easy way to improve your riding.