The calculation of nonce is through trial-and-error that miners do by attempting to guess what the value could be. The value of target is dynamically calculated, you can check its calculations here:
https://en.bitcoin.it/wiki/Difficulty