Yeah, have you changed the detent/spring? Or perhaps lost them when you took the stock off? Those can wear and be totally nonfunctional at times. Make sure the take down pin will accept the detent --even if it's loose, it should still "click" into place.
Those little red rubber plugs will make the upper lock tighter to the lower if it's a clearance issue, they're perfect for this kind of situation. If you get more rifles later, you can go ahead and swap lowers and see if that helps any. Some fit tighter than others and I've seen 'em where you gotta drive 'em out with a punch or continuously put the damn thing back in like you say.
Some lowers have less room because they aren't cut for DIAS. If your lower is that way, simply take that red rubber plug and sand some off the bottom bit by bit till it fits like you want. Remember, that plug will weaken over time so it'll need to be replaced yearly or so IIRC, and due to that you want it to fit as tight as you can get it. Some lowers, like the MEGA lowers, they have an extra hole threaded where you can actually Loctite a screw in to butt up against the lug and make it snug (but I never use 'em).
So new detent, spring and one of those red plugs if need be or wanted. Should cost you all of $3 to fix this.
In the future, try to get alike manufactured uppers and lowers, get matched sets or match them yourself at the dealer.
Finally, if you suspect the lower or upper is out of spec, you can have it measured. If it's not to spec, you may be able to get it replaced. Been down that road too, Rainier and Mega were champs about it.
Wish I could remember what those red plugs were called. Sorry. But someone will chime in or you'll find 'em easy enough. Everyone sells 'em.