So, a couple things.
Walkbys (any sims):
If they're walkbys and they happen to already be leaving at the time you try to start a conversation, you usually can't interrupt them leaving.
If they aren't about to leave, you can chat briefly. But they do still have a walkby timer running, so at some point they will leave and you won't be able to stop them.
But, if you use "Ask to Hang Out," and they say "Sure I can hang out for a bit," then the timer changes from the walkby timer to the longer timer used for friendly visits, several sim-hours.
Celebrities: (if you meant sims who have a celebrity rank in the game)
You can't interact with celebrities beyond the "Attempt introduction," "Ask for selfie" and the couple other interactions at first. If Attempt Introduction fails, the conversation will end and the celebrity will probably walk away. You have to wait till next time you see that celebrity sim and try again.