Notice that $Q=S^{-1}A$ and $M\otimes_AQ\simeq S^{-1}M$, where $S=A-\{0\}$.
Choose a basis of $S^{-1}M$ over $S^{-1}A$, say $\{\frac{x_1}{s_1},\dots,\frac{x_n}{s_n}\}$. Let's show that $x_1,\dots,x_n$ are linearly independent over $A$: if $\sum_{i=1}^na_ix_i=0$ (in $M$), then $\sum_{i=1}^n\frac{a_is_i}{1}\cdot\frac{x_i}{s_i}=\frac01$ (in $S^{-1}M$), so $\frac{a_is_i}{1}=\frac01$ in $S^{-1}A$, hence $a_i=0$.
For the converse, let $x_1,\dots,x_m\in M$ be linearly independent over $A$. Then $\frac{x_1}{1},\dots,\frac{x_m}{1}$ are linearly independent over $Q$: if $\sum_{i=1}^m\frac{a_i}{s_i}\cdot\frac{x_i}{1}=\frac01$ then $\sum_{i=1}^m\frac{a_ix_i}{s_i}=\frac01$, so $\frac{\sum_{i=1}^ms_i'a_ix_i}{s}=\frac01$, where $s=\prod_{j=1}^ms_j$ and $s_i'=\frac{s}{s_i}$. Then there is $t\in S$ such that $t(\sum_{i=1}^ms_i'a_ix_i)=0$, so $ts_i'a_i=0$, hence $a_i=0$.