Peter has always liked her and they have always been close friends per what we've seen. In fact it would even seem like MJ likes Peter in Spider-Man: Homecoming before Peter even realises he likes her back. We catch a few glimpses of her thinking about him or staring at him, like at the end of their last exchange in the first film. And a few other times she just appears to "make fun of Peter" due to something he's recently done or said which means she was probably listening in on him.
We just don't see much of their relationship because it isn't relevant to the plot of the first film and would just get in the way of things; it wasn't needed. There are also two other reasons why we don't see it develop:
- Peter is longing after Liz and it would only make things weird and complicated to add in the MJ angle too.
- The film is from Peter's perspective not MJ's.
It's also worth noting that MJ has a close guard up and plays things pretty close to her chest and portrays a "I don't care" attitude which only really drops as the pair's relationship develops in Spider-Man: Far From Home.
Of course she does start to drop this guard at the end of Homecoming and that would have enabled the pair to start getting closer off screen.
Michelle Jones: Uh, thank you. My friends call me M.J.
Ned Leeds: I thought you didn’t have any friends.
Michelle Jones: I didn’t.
We also have to consider that a lot of time passed from Homecoming to Far From Home with Liz out of the picture and MJ and Peter getting closer off screen. Homecoming takes place in 2017 and Far From Home probably takes place in 2023. Now both were snapped in 2018 and Far From Home starts not long after Endgame ends. Even so that's at least a year off screen that the pair have had together that we have not seen. It's irrelevant detail of the two getting closer that wasn't really needed and so was skipped. Remember the MCU also skips the Spider-Man origin story with Uncle Ben's death because it was done too much recently so also probably why large parts of the MJ/Peter beginnings are cut out.
However, of course things are referenced in Far From Home when Peter is telling Ned about his plans for the trip with MJ. This short sentence gives a hint at what has been happening with the two in the time gap.
Peter Parker: Okay, sure, but... I really like MJ, man. Okay? She’s awesome, she’s funny in a sort of dork way, and sometimes I catch her looking at me, and I feel stood up... Wait. Dude, she’s coming now. Just don’t say anything.
Spider-Man: Far From Home
In short it makes perfect sense anyway but a lot of the boring, awkward middle bits of their relationship are cut out because it wasn't needed for the films.