It all depends on how unlikely the event is, how vital the event is to the plot, and whether the reader/viewer has enough time to notice the holes.
For an example of bad plot-conveniences, consider the opening half-hour of Star Wars: A New Hope. Luke's reason for leaving Tatooine comes back to a crashlanded droid showed a transmission about someone called "Kenobi". We can discount the coincidences of the droids crashlanding on Tatooine and getting picked up by Jawas, because otherwise the Stormtroopers would never have come looking for them; and the Tantive IV wouldn't have been heading for Tatooine unless it was where Kenobi lived. So at least we don't have to justify why it's happening on that planet; and Jawas being Jawas, it's far more likely for the droids to be picked up by scavengers than that the droids stumble onto an outpost. But after that, the coincidences just stack up.
- The Jawas don't visit anyone else before Owen (or at least no-one else wants the droids).
- Owen happens to have had a droid fail on him the previous week, otherwise he wouldn't need one.
- The other droid Owen buys from the Jawas fails immediately, otherwise he wouldn't need R2-D2.
- Owen decides to buy both droids. (If he hadn't bought them, Luke wouldn't have met them.)
- Luke has the necessary skills to enable R2-D2 to show the transmission.
- Luke has transport.
- Luke makes the connection to "Kenobi", a man he only knows by reputation, in spite of Episode 3 allegedly having Kenobi set up home on Tatooine to look after Luke.
- Luke has the necessary curiosity (and boredom!) to go off on a highly dangerous trip to find Kenobi in spite of not knowing where he lives, instead of just telling R2-D2 and C-3PO to get on with their work.
- Luke leaves before the Stormtroopers arrive, and doesn't (for example) spend the morning fixing the moisture collectors instead.
- The Sand People don't just snipe him from a distance. (One of them considers it, but another one stops him for no obvious reason.)
- For no reason at all, the Stormtroopers shoot Owen and Beru and torch the homestead. Had they asked questions first, Owen would happily have told them that he'd bought the droids, Luke had vanished with them, and they just needed to wait for him to get back. At worst, they would all have died there. At best, the Stormtroopers would just have confiscated the droids, and Luke would have lived and died on Tatooine without ever joining the Rebels.
- Vader is unaware of the presence of both Luke and Kenobi on Tatooine, and Kenobi is similarly unaware of Vader's presence in orbit.
Not good, right? Of course if you push the plot forward fast enough then no-one really notices, so whether you get away with it or not will entirely depend on your writing style.
As @Andrey pointed out in a comment, all these take place in the first act. Some level of coincidence is usually required to set up a story where the little guy beats the big guy, because otherwise the story would just be "the Empire wins, game over". The issue for good writing is just how much coincidence your reader/viewer can stand before they say "wait, what?" @KevinWells has tried to justify this by "the Force exists, therefore it's destiny and not coincidence", but that really doesn't solve the problem because it takes agency away from the characters.
Conversely, Luke calling to Leia on Bespin in The Empire Strikes Back is a pure deus ex machina. We have no reason at that point to think this would do anything, we don't know they're brother and sister (and even Lucas hadn't written that yet, otherwise the kiss on Hoth wouldn't have happened!), we don't see him particularly using the Force in any way that Yoda might have shown him, and generally it just comes out of nowhere. Lucas has put Luke in an impossible position, and his only way out is to say "magic happens and the problem goes away".
Again as @Andrey says to make a very good distinction, deus ex machina happens at the end. It's not the setup to the story, it's the resolution. If the resolution is just "suddenly they're free/safe because magic happens", that's weak writing. Again, it takes agency away from the characters. There are times when characters should be left without agency (the point of most Godzilla-type monster movies is that the protagonists can't beat the monster), but that changes the nature of the story and you need to be careful not to leave your audience frustrated that you've invested all this time in characters who are snuffed for no particular reason.
It's probably not stretching too far to say that if you look at George Lucas's work, then you'll get good writing by doing the opposite of what he does. (As Harrison Ford famously said, "George, you can type this shit, but you can't say it.") On the other hand, Lucas's work has earned billions of dollars, so don't forget that good writing and popular, profitable writing are not always the same thing!