If I had to guess, I would likely say that you're inadvertently miscalculating or under-reporting mean caloric intake. The problem with some tracking apps (myfitnesspal in particular) is that it relies largely on user-submitted data which can be prone to error. I've encountered some items that have been "off" by upwards to 500kcal just based on macros and calories not matching up, incomplete or inaccurate data.
I would suggest starting with something like cronometer (draws info predominantly from gov databases and has a better degree of accuracy) just to help you better navigate tracking. Macros can be tedious, but it would offer a consistent approach. Try and keep it simple, aim for higher protein in fat loss phases (200-300g generally as a minimum), maintain fat around 45-75g and fill the remainder with carbs. For the most part, protein and fat can remain within the same ranges, and carbs can be adjusted based on training demands (higher leading into heavier sessions, lower end for less activity etc)
I'll also mention, that in tracking only protein it can become very easy to over-consume hidden fats (fats used in processing, cooking, etc) and under estimate your calorie intake. Again, a macros approach can be tedious, but can help to make sure you're eliminating any possible discrepancies and once you develop more consistency you can easily return to a more intuitive eating approach. An added benefit of Cronometer too, in my experience, is far more accurate micronutrient data as well - aim for adequacy in all areas as any long-term inadequate intakes or deficiencies can lead to issues when dieting down.
Hope this helps.