Another possibility is that Beckett is trying to make someone else jealous. In the world of fanfic, there could be a complex web of relationships. He might be using this flirting as a tactic to get the attention of another character, perhaps someone he has a more complicated relationship with, like an ex - lover or a rival.
Imagine a fanfic where Beckett is at a library. He notices a man looking for a book. Beckett, being the flirt he is in this story, offers to help. As they search for the book together, Beckett brushes his hand against the man's a few times on 'accident'. He also makes some flirty comments about how smart the man must be to be interested in that particular book. Soon, there's a definite spark between them.
Well, it could be that Beckett is in a parallel universe where he has a different life and he's in bed with another man. In this story, they could be discussing their different worlds and how they got there. Maybe Beckett is an undercover agent and he has to pretend to be in a relationship with this man, so they are in bed just to keep up the pretense for some important mission. It could also be a story about Beckett's past life where he had a relationship with a man that he's now rediscovering while in bed with him.
Perhaps the man is a new partner Beckett has been assigned to work with on a case. Castle sees them together and his insecurities get the best of him. He starts imagining all sorts of things, like Beckett replacing him in her life. However, in the end, it turns out that Beckett has no romantic feelings for the other man and Castle realizes he overreacted.
It could be that Alexis is being influenced by someone else. There might be a third character who has their own agenda and convinces Alexis to go after Beckett. Also, Alexis might have some internal issues, like self - esteem problems. If Beckett is constantly achieving things that Alexis feels she can't, it could lead to feelings of inadequacy and then the urge to bring Beckett down.
One possible plot could be that Beckett is kidnapped by a rival group who wants to use his skills or knowledge for their own gain. His friends then embark on a dangerous rescue mission.
Add some mystery. For example, the man in bed with Beckett could have a hidden identity or a secret mission. This would keep the readers guessing and make the story more engaging.
He might get jealous right away. He could storm off and then later come back to confront Beckett about it.
One possible plot could be Beckett's intense search for the abducted child. She might use her detective skills to follow leads, question suspects, and piece together the mystery of the abduction. Another plot could involve the emotional journey of the people related to the abducted child, like the parents, and how Beckett interacts with them during the investigation.
Well, it could be that Beckett's mystery illness is actually a curse. In the fanfic, there might be a magical or supernatural element. For example, an old family feud with a witch or a wizard who put a curse on Beckett, and the story could revolve around breaking the curse to cure the illness.
It could also be a fanfic that takes place in an alternate universe. In this universe, the events of 4x23 didn't happen as they did in the show. Maybe Beckett didn't become a detective in the same way, and Castle meets her in a completely different situation. They then start to solve mysteries together in this new setting.