Assassinate works as written
Assassinate does not guarantee a critical hit if the assassin initiates combat from stealth. It only guarantees that if they hit a surprised opponent, that hit will be a critical. They can still miss the victim on the surprise attack, or the victim can beat their initiative and stop being surprised before they can get to attack.
A surprised creature does not skip its turn, it just cannot act or move on their turn, or react until they took their turn. The mechanics of surprise work, as written, there is no bug to be fixed (other than maybe that they are somewhat unintuitive, especially for long-time players who remember the concept of a surprise round, and so cause a lot of confusion).
Here are the gory rules details:
Assassinate says:
Starting at 3rd level, you are at your deadliest when you get the drop on your enemies. You have advantage on attack rolls against any creature that hasn’t taken a turn in the combat yet. In addition, any hit you score against a creature that is surprised is a critical hit.
Surprise is described on p. 189 PHB, the procedure is in the box Combat Step by Step:
- Determine surprise. The DM determines whether anyone involved in the combat encounter is surprised.
- Establish positions. The DM decides where all the characters and monsters are located. Given the adventurers’ marching order or their stated positions in the room or other location, the DM figures out where the adversaries are— how far away and in what direction.
- Roll initiative. Everyone involved in the combat encounter rolls initiative, determining the order of combatants’ turns.
- Take turns. Each participant in the battle takes a turn in initiative order.
- Begin the next round. When everyone involved in the combat has had a turn, the round ends. Repeat step 4 until the fighting stops.
The DM decides who is surprised. Some standard ways you get to be surprised are:
If neither side tries to be stealthy, they automatically notice each other. Otherwise, the DM compares the Dexterity (Stealth) checks of anyone hiding with the passive Wisdom (Perception) score of each creature on the opposing side. Any character or monster that doesn’t notice a threat is surprised at the start of the encounter.
The effect of surprise is:
If you’re surprised, you can’t move or take an action on your first turn of the combat, and you can’t take a reaction until that turn ends. A member of a group can be surprised even if the other members aren’t.
Technically, this does not say that the surprised condition even ends at the end of the creature's first turn (although almost everyone understands it that way). That this is the case has been clarified in a Sage Advice Compendium entry:
For triggering the rogue’s Assassinate ability, when does a creature stop being surprised? After their turn in the round, or at the end of the round? A surprised creature stops being surprised at the end of its first turn in combat.
As you can see from the list above, everybody needs to roll initiative before any turns (and with that, attacks) happen. Even the unaware, surprised creature. There are no attacks outside of combat and there is no combat without initiative. And it is possible that the surprised creature beats the assassin's initiative — how you rationalize this is up to your creativity.
So in the first round of combat, if you are surprised and your initiative is after the assassin's, the assassin can take its turn while you are surprised and will auto-crit you if they hit. They get to make their attacks with advantage for that, because you have not taken a turn yet.
If you are surprised and your initiative is before the assassin's, your surprise will end with your turn. You still take your turn, you just cannot act during your turn. The assassin then will neither get advantage to their attack, because you have taken a turn, nor will they get to auto-crit if they hit, as you are not surprised any more.
Based on your comment: what may be confusing you is that you think an assassin can somehow attack someone "outside of combat" if they ambush them. That is just not the case. As soon as one side, even if undetected by the other side, wants to initiate hostilities, the above five-step procedure is triggered: the DM determines if they are surprised, where everyone is, initiative is rolled, and so on. Only then can they attack.
(There may be some ambiguity if you can Ready an action outside of combat, to get the drop on someone. For more on those topics see also: When and how does combat start in a standoff?, and How to resolve surprise and "instant actioning" initiating combat — the rules are not conclusive here, so in the end the DM must decide. I think a practical way to handle it is to let the party lying in wait automatically win initiative, if the wait is short enough, but another DM may handle it differently.)