The trade tend to prime skirtings before doing the cutting and fixing, install architraves, then skirtings, sand out any discrepancies (such as architrave joints which aren't flat or scarfed joints on long runs of skirting), then fill and sand any pin holes, etc before glossing.
We invariably use 2nd fix (16 gauge) nailers and grip adhesives for the skirtings and 2nd fix nailers for the architraves with a 2-part mitre adhesive such as Mitre Mate, etc being used to glue the architrave mitres (bonds in seconds, not hours like PVA). Once the grip adhesive has gone off the gaps to the wall are dealt wiith by acrylic decorators caulk. The pins are really only used to hold the skirtings in place whilst the grip adhesive goes off (12 to 24 hours), nothing more, For DIY work the 2nd fix nailer and pins can be replaced by what we used before the advent of guns - hammer, small oval nails (or lost head nails/panel pins for architraves) and a nail set (to punch nail heads under), but TBH foam is probably a lot easier
On some jobs these days we use low expansion foam instead of grip adhesive for skirtings - generally where we need to fix to metal-frame studwork walls - but it is slightly more expensive, plus a bit slower to use, and if you are trimming out an office complex or a block of flat the preference is still for grip adhesive on cost grounds
The reason why you prime timber before fixing is to protect the backs and bottoms but it also makes the decorator's job faster.
The reasons why you gloss skirting
after installation, particularly if you are pinning, are many: cutting freshly glossed materials in a mitre saw or even a manual mitre box risks damaging the paintwork (both from contact with the fences as well as chipping or pulling where the saw cut is made) as well as risking transferring paint onto your equipment; same goes for making any scribed ends; when installing skirting with pins or nails they leave holes which needs to be filled, sanded and then painted in - with gloss paint that may mean a large repair area because a dob of gloss applied a few days after the original paint always shows
Architraves really have to be pinned in place, not glued, unless you want them to fall off! The standard approach is to mark-out your reveals (set-backs) - generally 5 to 10mm depending on the rest of the house and the size of your hinge knuckles. First you cut the header to size with the two end mitres and pin that in place, then measure from the top of the architrave head to the floor on both sides and cut the two legs about 5mm oversize with the end mitres cut. The legs are them offered-in
upside down (point to the floor) so that an exact fit from floor to top edge of the head is marked and the legs can be trimmed, if needs be with a hand saw. The mitre faces are then coated with mitre glue, the leg is moved into place and held whilst the mitre joint sets (10 to 15 seconds). That leg can then be nailed/pinned to the door casing and any nail heads punched under with the hammer and nail set. Any holes are filled and sanded, and if the mitre joint at the top isn't perfectly flat, and/or you have any glue squeeze out, the mitre is also sanded flat. So a lot of handling.
We do install pre-finished materials from time to time - it's generally 2-pack lacquered material which has been properly cured and which when fully cured is a lot tougher than gloss paint making that feasible, but even there we still pin the architraves, either with 18 gauge pins or 23 gauge ones, holes being filled with coloured wax
So a professional would install, fill, sand and paint - produces a better result than trying to touch-up afterwards
As for masking, you'll never see a professional decorator doing that on standard skirtings or architraves - to get a decent line they use something called an angled cutting brush. A decorator I worked with quite recently recommended
this very affordable ProDec one (£2.81) from Toolstation. together with a
set of the ProDec synthetic brushes (12 brushes at £16.47). I used them on some snagging work and for both emulsion and oil-n=based gloss they were surprisingly good - certainly better than any cheap brushes I've had in the past