まあ has several distinct uses that are told apart mainly by intonation and context. It is always written in kana.
HESITATION / SOFTENING (drawn-out, falling tone): softens a statement or turns firm agreement into a mild concession — "well…", "I guess". It typically opens a sentence, often before いい, そう, or a guess like だろう, making the whole remark tentative rather than definite.
SURPRISE (short, rising tone): a standalone exclamation of mild surprise or admiration — "oh my!", "oh dear!". This use is traditionally feminine and now sounds somewhat old-fashioned. It comes before the thing noticed (まあ、素敵!).
MODERATE DEGREE (reduplicated まあまあ): means "so-so, passable" — neither good nor bad. Used on its own, before an adjective (まあまあ美味しい), or as まあまあの + noun ("passable results").
CALMING (まあまあ、 said soothingly): the same reduplicated form used to calm someone — "there, there", "now, now" (まあまあ、落ち着いて).