Most basic ones are just 2 dissimilar metals, one as each electrode,
plus a small meter. Thats it. Cost a tenner from garden centres, but
you should be able to make one from junk if you want.
The explanation you can find in any textbook on general chemistry, in
your local library.
As to buying an instrument, that depends on the precission you require.
They start with cheap soil pH-meters from a garden centre, and end at
4-figure laboratory instruments. Also, electrodes can be solid state
(ISFET) or glas-electrodes (which require a lot more care).