For example, citric acid has three acidic protons, all of which are carboxylic acids. Despite being part of the same functional groups, they all have very different pKas. Why (and how?) is this?
2 Answers
Here is a picture of citric acid.
As you noted, there are 3 carboxylic acid groups in citric acid, so there are 3 acidic protons. A chemist looking at this unionized molecule would say that the carboxylic acid group drawn on the right side of the molecule is equivalent to (the same as) the carboxylic acid group drawn on the left. Therefore, these 2 equivalent carboxylic acid groups should have the same pKa. The carboxylic acid group drawn in the middle of the diagram is different from the other two (it is not the same as the other two) and should therefore have a different $\ce{pKa}$. In chemistry, groups are either the same or different. If they are the same they must be indistinguishable in all aspects, including physical properties like $\ce{pKa}$
That said, we might expect when we treat citric acid with more and more base to see only 2 different $\ce{pKa}$'s, but that is not the case. In actuality when we treat citric acid with base one of the two different (right and left or middle) carboxylic acid groups will ionize. Once that happens the ionized citric acid molecule contains a negative charge. It will be harder to ionize the molecule again and remove the second proton and place a second negative charge on the molecule (bringing like charges together is destabilizing and costs energy). The same argument tells us that removing the third and final proton will be even more difficult because we wind up with 3 negative charges on the molecule. As a consequence of this increasing difficulty to remove protons, we observe 3 different $\ce{pKa}$'s.
Let's begin this discussion with the simpler oxalic acid.
O
#
HO-C-C-OH
#
O
There are two carboxylic acid functional groups, and there are two different pKa's. This is because double deprotonation does not happen simulateneously. One gets deprotonated first, then the other. After the first deprotonation, the residual molecule has a negative charge. The result:
O
#
HO-C-C-O~
#
O
Is much less acidic because the presences of the carboxylate functional group changes the acidity.
Let's continue the discussion with the (still simpler) alpha-chlorosuccinic acid:
Cl H O
| | #
HO-C-C-C-C-OH
# | |
O H H
The acid closer to the chlorine is more acidic because the chlorine is strongly electron withdrawing, and 'pulls' the electrons out of the carboxylate function, which then 'pulls' electrons away from the hydrogen, making it more acidic. This effect decreases with distance, so the chlorine pulls on the acid function farther away less strongly.
In a more generalized way, remote groups will modify acidity because of electron withdrawing or donating effects, but the farther away from the acid function, the less effect there is.
For citric acid, there are actually two different flavors of acid function, so one of the kinds will be intrinsically more acidic before deprotonation because of the remove effect. However, because of the sequential deprotonation discussed above, all three will have different pKa's