To agree with something: something must be a statement, for example 2+2=3. If you think this is correct, you are agreeing with it.
To agree on something: again, something is usually a statement (occasionally an agreement, see below). If several people have the same opinion of it, they agree on it. For example I expect you and I agree on 2+2=3, in that we both disagree with it (I hope!).
FWIW to agree TO something: something is a commitment of some kind - an agreement. If I promise to pay you £5 tomorrow, I am agreeing to pay you. You and I could agree to (or on) that, too.