Imaginary friends are getaway friends most kids create to get away from their travails, some of the fantasy friends created remains in the memory of the creator even as adults. I still remember most of my created fantasy friends, its mostly common when a child has a troubled home, missing parents, sick parents or siblings and any other thing that makes a child not happy at some point while growing up.
An Adult sometimes never part with their fantasy friend, although any grown up seeing talking to imaginary beings could be labelled a loco, but it is a thing, some adults prefer to talk and share their minds to Teddy bears and maybe some other inanimate objects when they feel sad or lonely. As weird as this sounds, I'll say its more preferable to talk to a Bear or stuffed Bunny than share your emotions with some friends that will sooner or later come back to throw a jab at you with those words.
It hurts when your secrets shared with a supposedly trusted friend or family is leaked to some other friends, no secrets as ever remained a secret in this life, everything always come out in the open. Hence, adults needs imaginary friends like kids too, it saves you a lot of heartbreak when you talk to a stuffed animal or a pet, they will look at you and blink without judging you, that's if they understand the mumbo jumbo you are saying to them.
I will never judge anyone on the roadside or on a bus lost in thoughts and speaking to themselves, who knows, they might be having a conversation with their trusted imaginary friends!