The answer: Nothing. Take that in. You’re probably not doing anything wrong. Think about it -- you keep getting interviews, so your resume and cover letter must be in good shape, and/or you’re reaching out to strong contacts. The interviewers are offering you feedback instead of just ghosting you -- a real rarity in this day and age -- so you must have made a good impression. But alas, you’re still not getting the job. The question isn’t "What are you doing wrong," it’s "Why aren't you getting the job?"
There are loads of reasons you can come very close to a great job but still miss the mark. First of all, maybe the company decided to hire internally -- a common occurrence. You don't have much of a shot against someone who already understands the way the company functions. Other times, someone else has a stronger contact at the company. Maybe you were referred by the assistant’s friend, but the boss’s friend also recommended a great candidate. That happens more often than you might think. Sometimes, the hiring manager can tell you’re great at what you do, but there’s someone else who fits in better with the team personality-wise -- this is especially true at small companies where they’re looking 40% for skill and 60% for a new best friend. What do all of these reasons have in common? They’re beyond your control, and you shouldn’t worry about them.
If you keep doing what you’re doing, you will land a job that’s the right fit. You’ll find a company where the stars align -- you have the right qualifications, a strong referral, and you get along great with the team. The worst thing you could now, actually, is change anything up or lose confidence. Don't forget that you're a highly desirable candidate -- it might take longer than you'd like, but you're doing everything right, so you will wind up with the job that's perfect for you.