Dogs are like that as are most animals especially when young. No different than a child being alone. imo
Our dog and former cat kept each other company at night and played around some. neighbor got an excellent little dog. No company so he was always up at our house with our dog. Only problem was he dug up everywhere and chewed up things.
We had one young pup, long ago, that I ended up letting it sleep, in our bedroom with my hand dangling down next to him. In a short time he got independent. Someone stole him a bit later.
Each dog is different. Brother In Law had a find looking minature collie. He tried everything with the anxiety and some other things. Turned out the dog was crazy and had to be put down.