I make the whole system without flanges. Then, one place at a time, I pull a pipe end back leaving a gap (this separates everything into two systems) place flanges on the end(s), grab the face of the flange by its connector symbol, and drag it back into place on an accessory or another flange (they connect and everything becomes one system again.
Flanges disappear when you change a pipe in any way that causes a recalculation in Revit, because Revit checks the routing setup again and sees that the pipe type isn't supposed to have flanges. It's easiest for me just to add them back in on the occasions this happens, but I've seen two work-arounds as follows:
1. Call your pipe type something like "SCH40-BLK-WLD". Duplicate it and call the new one "SCH40-BLK-FLNG". Set the routing preferences for this new type to have flanges. Change the pipe in your project to the FLNG type only where you've got flanges, and then they shouldn't disappear anymore.
2. Split the pipe right near flanges. This should (if you've set up routing preferences correctly, add a union(coupling) at the split. Now you can make changes to the pipe on the other side of the union and the recalculation only goes as far as the union, so it doesn't get all the way to the flange and delete it.
I've tried both of those, and they've both still got wonky behavior. So like I said, it's just easier for me to put flanges back in occassionally. Anyway here's a pic proving my flanges all connect. Just have to drag their connectors to the mating connector correctly.