I thought it was by having pros with steady scores on other courses play and then decide what the average pro would shoot on that hole.
But now they are laying out a course in town and know the par before even all the grading is done. What if their “par 3” turns out to be really tricky? Would they have to renumber it, or would it just become a “tough course”?
I think it’s normally based on yardage, and not much else.
Generally a hole is laid out with one, two, or three shots expected to be needed to reach the green. While there may be some doubt at times, for the most part this isn’t too tricky. Two putts are assumed, giving you a par range of 3-5.
There may actually be accepted yardage delimiters - I’m not sure. This page, which doesn’t look like the most authoritative of sources, nevertheless gives these ranges:
250 yards and under = par 3
251-470 yards = par 4
471 yards and over = par 5