Maybe they stumble upon a government conspiracy. The government wants to keep something hidden and they are seen as a threat, so they are made to disappear. It could also be related to a scientific experiment gone wrong. They are in the wrong place at the wrong time and get caught in an energy field that transports them to an unknown location, causing them to disappear from their normal world.
One possible reason could be that they are on a secret mission. Maybe they are trying to protect a key witness or important evidence from a powerful and dangerous criminal organization. In the world of fanfic, this could lead to them having to disappear to keep their whereabouts unknown.
Perhaps they are trying to protect their relationship from outside interference. For example, if there are people in Castle's publishing world or Beckett's police department who don't approve of their relationship, they could pretend to be separated to avoid any negative consequences. This would allow them to still be together in private while keeping up the appearance of being single in public. Also, it could be a way to test their relationship. They might want to see how they would fare on their own and if their feelings for each other are strong enough to withstand a period of 'separation'.
It could be a vengeful criminal that they put behind bars. This person has escaped and wants to get back at them, so they engineer their disappearance. Maybe they have a whole elaborate plan to torture them in some remote location.
Maybe he's afraid of losing her because she's his partner and they've been through so much together. Their relationship is very important to him.
One possible plotline could be that the baby has some sort of special ability or is in some way connected to a mystery they have to solve. Maybe the baby's birth coincides with a strange series of events in the city, and Castle and Beckett have to use their skills to protect the baby and figure out what's going on.
One possible reason could be a change in character development that diverges from the original show's trajectory. Maybe in the fanfiction, the writer wants to explore new relationship dynamics where Castle has different feelings. Another reason might be to create conflict for the plot. By having Castle not love Beckett, it can lead to a series of events that test their partnership in a different way.
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.
Jealousy could also play a part. Castle is often surrounded by beautiful and adoring fans as a famous writer. Beckett might start to feel insecure, especially if she sees some of these fans getting a bit too close to Castle. On the flip side, Beckett's dedication to her work and her male partners in the police force could make Castle jealous, ultimately leading to their break - up.
Maybe he saw Beckett spending a lot of time with another man without knowing it was for a case. Castle is a bit of a jealous type, and he might overreact to normal interactions.
It could be that Castle is overprotective. He loves Alexis so much that even the slightest sign of Beckett not being on the same page as Alexis in Castle's eyes makes him think Beckett hurt her. Maybe Beckett gave Alexis some career advice that Castle thought was too pushy.