Without being a programmer or a computer expert, how can I know if a particular program or any piece of software in general doesn't have hidden unwanted functions compromising privacy and security?
You can know whether some software does only what it announces in the same way that you can know whether the food they serve you at restaurants is poisoned or not. In plain words, you cannot, but Society has come up with various schemes to cope with the issue:


You can listen to friends and critics to know if the food at a given restaurant has good reputation or not.
You can take a sample and send it to a lab which will look for many (but not all) known poisonous substances.
You can ask nicely if you may observe the cook while he prepares the dishes.
The cook has a vested business interest in his customer being happy with the food quality, and happiness includes, in particular, not being dead.
Society punishes poisoners with the utmost severity and it can usually be assumed that the cook knows it.
You always have the extreme option of not eating there if you are too worried.


All of these can be directly transposed into the world of software. Extreme methods of ascertaining software quality and adherence to its published behaviour include very expensive and boring things like Common Criteria which boil down to, basically, knowing who made the program and with what tools.

Alternative answer: every piece of software has bugs, so it is 100% guaranteed that it does not do exactly what it is supposed to do. (This assertion includes the software which runs in the dozen or so small computers which are embedded in your car, by the way.)
