You'll have to learn by trial and error.
It does involve a lot of back and forth. If you paint the PE on the fret, you need to go back and touch up the cuts. That's fine and part of the process, and will get you to thinking that if YOU were the fret designer, YOU would have put the attachment points in entirely different locations.
If you cut the parts off the fret first and then paint them, you eliminate that problem, but they have to be held onto. I often stick them down on the sticky side of a piece of tape that I've either taped or pinned to my painting surface.
If the PE is one sided, and a lot of it is, like watertight doors, ladders, hatches, hull fittings etc. it makes all the sense in the world to glue them onto the bulkheads, hull, deck or whatever and paint it as an assembly.
So it all depends on the circumstances.
And yes on railings, I paint them after cutting off of the fret, usually before bending, and then glue them on. That means a little touch up at the bends. But railing parts are usually big enough to hold onto while painting.
I'll throw in one more piece of my own advice about railings, that will probably provoke more discussion.
I never join them at the corners, always somewhere in the middle of a straight run. Many reasons for that. First, the part then has rigidity and will stand up on it's own. Second, to do a corner right as a joint, you need to cut off the end stanchion on one side, letting the horizontal bars run "bitter". And if you study the railings on a ship, they really are interrupted all the time with stuff like mooring cleats, gun shields, ladders, piping and all the other stuff that clutters up decks. And the stanchions rarely march along in perfect order, except for the main deck lifelines (more on that in a sec.).A little planning ahead can make that work for you.
I mainly model pre-dreadnaught ships, which did have pipe railings of the two bar variety all over the place, or chain. A big World War 2 ship, on the other hand, usually had a system of collapsible stanchions all around the main deck that the deck department set up and ran line through, or took down for battle so that it didn't get burned up. Which meant that the stanchions would be dark blue, but the line is gray or tan. I made an attempt to replicate that on my heavy cruiser, and am pleased with the results. I painted the PE tan, and painted the stanchions blue by making a puddle of blue paint on the bench (on a piece of tape), and dipping the edge of a #11 into it and pressing down on the stanchion. Went quickly.
Good conversation and I'm learning a lot. I will try not priming PE. Does that include the Chinese stuff? My Bronco Ting Yuen came with a super thin clear film on one side of the PE that I didn't even see until I primed the fret. What a mess!