Can you form alliances between the main story factions?
Minutemen
If you finish the game with one of the other three factions, you can still be allied with the minutemen. It's probably not as formal of an alliance as you're hoping for. If you specifically support the Minutemen, then you'll be at war with the Institute, and potentially the other factions as well.
Other Factions
The other factions have deep-seated philosophical differences that prevent any kind of accord among them:
The Institute believes that their science, and their synths in particular, are the future of mankind. The Brotherhood of Steel believes that no one else can be trusted with advanced technology.
The Institute believes that synths are tools to be used as they see fit. The Railroad believes that synths are sentient beings with the same rights as humans.
The Railroad wants to help synths to establish normal lives as peers among humans. The Brotherhood believes that synths are abominations of science that must be destroyed before they result in humanity's extinction.
This means that supporting any of these factions results in the destruction of the other two.
Actually, there is an order in which you can do quests so the minutemen brotherhood and the railroad all make it out alive. There also happy about the end. I have a list of the quest order that i will be adding when i find it. If you go to youtube and look up, fallout 4 best ending, it well tell you how to make all three factions get along.