Here are two of my relevant stories:
Indian Dude #1
We hired a dude after a long screening and interview process and he lasted 1 week.
I did not want to hire him because he had a 65 mile commute each way from as far south as you can get in The OC (Rancho Santa Margarita) to Burbank. Obviously he said that was no problem during the interview cycle but "C'mon Man", use some common sense, it's going to be a problem.
Since we really needed somebody, and we didn't have any other good candidates, we brought him on board.
A week later, he found a different opportunity closer to home and took it. Big surprise, huh?
Fast forward 8 years or so and I'm at a work conference event in Vegas and this dude comes up to me and is all like, "Hi, remember me? It's xxxxx, we use to work together." I'm like, uh, no.
I didn't even remember the dude. But, once I knew who he was, believe me, I wasn't doing him any favors.
Indian Dude #2
During the scamdemic, I had a lot of work and needed to hire some top shelf talent so I wound up hiring this guy from a competitor.
Dude was excellent. One of the smartest guys I've ever worked with. Learned everything quickly, and volunteered for work including travel (which was a problem for a lot of the people on my team in Blue States during the scamdemic).
The only problem I had with him was related to travel expenses which we corrected very quickly.
But, he only lasted 3 months because, coming to work for us was basically a way to get out from under a problem situation he was in at his employer. Once he was outside of the company, a different part of their business was able to come and recruit him to come back to work for them.
So, I was pretty irritated at the whole situation and I'd certainly never hire that guy again but, I am still glad that I hired him based on the amount of high quality work he did during the 3 months he worked for me.
Summary
If you plan to work with Company A anytime in the next decade, don't switch jobs.
If you don't care about burning bridges and there's no way you'd ever go back to Company A, then go ahead and take the job at Company B.
Do Not go to Company A and say, yeah, I know I just started here and really haven't proven myself but somebody else will pay me more, what are you going to do about it?
Bonus Story
I've got a friend who was a specialist in a specific Engineering thing that only two companies did.
He managed to get himself fired from Company A but landed a job at Company B.
The box he put himself in (due to his dalliances with staff at Company A) meant that if he got fired from Company B, he was going to be completely out of the industry. The point is that it's good to keep your options open and build relationships because you never know when you might need them.