Yes, the sentences are grammatical. As to the meaning, it depends on the context.
I was wondering could refer back to an occasion in the past when you spent time thinking about something. For example, I was wondering this morning what she thinks of me, but now I've decided I don't care one way or the other.
However, the I was wondering phrase often has nothing to do with past contemplation. It is used to make a present request or ask a present question. So, when you say to someone (e.g. your boss) I was wondering if you agree with me, you mean simply Do you agree with me?
The past tense (indicating remoteness) removes the directness of the request or question. The progressive form further distances the question, cf. I wonder if you agree with me.
Still more distanced and deferential would be the past tense in both clauses: I was wondering if you agreed with me.
Swan in Practical English Usage has a good section on this topic, entitled Politeness: distancing verb forms (p411).
- past tenses: How much did you want to spend?
We can make requests (and also questions, suggestions and statements)
less direct (and so more polite) by using verb forms that suggest
'distance' from the immediate present reality. Past tenses are often
used to do this. I wondered if you were free this evening.
- progressives: I'm hoping ...
Progressive forms can be used in the same way. They sound more casual
and less definite than simple forms, because they suggest something
more temporary and incomplete. I'm hoping you can lend me £10. (less definite than I hope...)
Past progressives give two levels of distancing: Good evening. I was wondering: have you got two single rooms?