Let's say you are PC1, engaging NPC1 and NPC2 in conversation. You make the decision to attack, in the middle of conversation, and you were previously not hostile to them.
When you decide to attack, initiative is rolled. Let's say you roll an 11, but NPC1 rolls 15 and NPC2 rolls 5. In this case, NPC1 effectively loses their first turn because they're still just engaged in conversation - they don't know that you're hostile yet, so they have no reason to draw their weapon or cast a defensive spell or anything. Then, you attack on your turn as normal. After your turn resolves, NPC2 takes their turn, and probably attacks or casts a spell now that they know you're hostile. On the next round, NPC 1 goes before PC1 goes before NPC2, as normal.
(Or the DM could rule that everyone has a chance to act in the first round of combat, because NPC1 sees you go for your weapon if they happen to roll higher initiative. A lot of it depends on who is standing where, and who can see what, which is why so much is left to DM adjudication.)
The most clear-cut situation is if you're a sniper, engaging enemies who are distracted. You want to shoot NPC1, so you roll initiative before you can do that. NPC1 has no idea that you're there or hostile before you make your attack, so they just go about their normal business. Then you attack on your turn, and then NPC2 goes on their turn. The difference here is that the enemies are probably surprised, if they don't know you're there, which means NPC2 also loses their first turn. Everything goes back to normal on the second round, though, with NPC1 going before PC1 going before NPC2.