Can you play Destiny 2 co-op missions with only two players?
It really depends on the type of activity you are playing. Since a third random player joined you, then you played what you call a matchmaking game type. Matchmaking will pair you up with random players who are also doing the same activity, up to the maximum number of allowed players.
You can tell if an activity is matchmaking by hovering over the icon and viewing the details. If it’s matchmaking, then there will be a line item that indicates as such.
Unfortunately, there is no way to disable matchmaking. You’ll always be paired with other players in matchmaking game types, unless your fire team filled all the allowed slots. The only exception to this is if you’re playing on a console and you don’t have the respective online subscriptions to access the multiplayer features.
You can still do activities with just you and your fire team. Non-matchmaking activities are typically, but not limited to, story missions, side missions, quests, or end game content (which, on average, require more than two people)