how does 10 folds method determine the best parameter in the end?
Strictly speaking: it doesn't.
The best parameter is usually determined by comparing the performance (which may be measured by cross validation - or by other methods) of a number of models that were built with varying hyperparameters. The hyperparameter value that lead to the best performance is then selected.
Remember that by such a selection, you "use up" the performance estimate: it enters the model training that way and that is the reason why you need another performance measurement of the final model that is independent also of this selection procedure.
here's an example: so I understand that each fold is compared against the other 8 for the best fit parameters by running it with the validation set.
No. Typically all 10 folds are evaluated with the same parameter (s).
Let's say the first time param A is selected, the second time around another fold is selected, let's call it param B.
No. The fold is not a parameter to select. Hyperparameter and fold (or more precisely: your whole performance measurement scheme) are independent of each other.
How does the method make a decision if param A or B is better?
You can tabulate your performance measurements (loss function values, errors) as table of case against parameter value, e.g.
parameter value: A B
case 1 L1A L1B
case 2 L2A L2B
case n L1A L1B
If you evaluate both hyperparameter values with the same cross validation splits (and of course for the same cases), you can set up the comparison as a paired test. For example, for each case you calculate the difference LiA - LiB and test whether that is different from zero. (This is just an example, there are other tests such as rank tests and not paired tests as well)