Oh, absolutely, story/cast reasons were the real reason - but while assigning an Ensign to a Commander slot is extreme, assigning people above their rank and above higher ranks in the process is not completely unheard of, even in today’s military. Given their utterly unique situation as an in-universe excuse, I don’t have any real problem suspending disbelief on Tilly’s assignment there.
A couple of quibbles that no one else seems to have brought up. Ensign Tilly was not promoted to XO - she was assigned to the position of acting XO while remaining an Ensign. The designation of “acting” makes it clear she’s just holding down the slot temporarily until Saru makes a more permanent selection, and makes it much more tolerable for those she’s now in charge of despite the lower rank. It probably wouldn’t have been tolerated (by the Admirals at Command) even in the lax standards of Starfleet, but even ADM Vance realized Saru had to pick from the tiny crew he brought to the future with him, so he let it go.
As for Ezri, again, remember that rank and position are only loosely connected, while rank and specialty (Counselor, science officer, engineer, navigator) are COMPLETELY unconnected. Ezri is a counselor because they wanted to make her distinct from Jadzia, and is an Ensign to highlight her inexperience both as a person and in dealing with a symbiote.
But yes, it does seem like the writers’ familiarity comes and goes. I swear there are at least a few episodes (and I can’t remember which series, because I’m alternating between three right now) where people refer to a Lt. Cdr. as “Lieutenant” instead of the proper term of address, “Commander.”
I guess the link didn’t make it through. https://www.printables.com/model/598216-stands-for-sanderson-sisters-funko-pop-set-no-supp