How are registration numbers assigned?
In the US, aircraft numbers are requested or reserved from an available list by the aircraft owner: N-Number Availability Query.  Then the owner, the manufacturer in the case of new aircraft, submits an application for registration with the reserved or available number.

This order of events (to reserve then request assignment) is important as registration numbers are applied to the aircraft, recorded in logbooks, programmed in computers, etc. before the aircraft certification is complete.

In the US, aircraft manufacturers reserve blocks of registration "numbers" long in advance of manufacture.  A registration request is made to the FAA on the appropriate form at which time a registration examiner at the FAA determines the legitimacy of the request: whether the number is assigned or available to be assigned to the aircraft as requested.

The Canadian process is the same.  Available Marks