Peter has been acting kind of weird for the last couple of years or so (he got his powers six months before Captain America: Civil War) so figure MJ has been interested in him during that time (not necessarily romantically, but he's been on her radar for a while as someone... interesting).
He also dated Liz during Spider Man: Homecoming and they only "broke up" because she moved away after her dad was arrested for being a supervillain. I don't remember if Liz and MJ were "besties" or anything, but Liz was a pretty, popular girl who clearly saw something to like in Peter. You ever hesitate to try a new restaurant but then go there because a friend tried it and really liked it? A little like that.
Finally, there really wasn't a "romance" between Peter and MJ through most of the movie. While each liked the other, they didn't even "declare their intensions" until after the final battle near the end of the movie. That was the point that the romance really began.