If you buy new forks, they have a long steerer tube that you normally have to cut down with a hacksaw. If you buy used ones, you need to make sure that the steerer tube is long enough because it's probably already been cut down. You will have to get some spacers to set the stem in the right position for the cap.
Next, you have to get the right diameter steerer tube, most MTBs have 1 1/18". Older and cheaper bikes have 1", and modern MTBs often have tapered ones. You have to get the right type for your steering head tube, I.e. the same size as what you already have.
There are two main types of headset - threaded and not threaded. You can change from one type to the other if you get a new headset. Obviously, you need forks with threads to go with a threaded headset, and the threads need to reach the right position considering the length of your head tube.