Localization of the $k\times k$-module $k\times\{0\}$ by $\{0\}\times k$
Let $k$ be a field, $R=k\times k$ and $M=k\times\{0\}$ endowed with a structure of $R$-module. Let $\mathfrak{P}=\{0\}\times k$, it is a maximal ideal of $R$ such that $R_{\mathfrak{P}}\simeq k$. I want to show that $M_{\mathfrak{P}}$ is not a free $R_{\mathfrak{P}}$-module, but I found that $M_{\mathfrak{P}}\simeq k$ which is free so I must be mistaken. Any help is appreciated.
Here is how I proceeded : $M_{\mathfrak{P}}=M\times(R\setminus\mathfrak{P})/\sim$ where $\sim$ is such that for $(m_1,x_1,y_1),(m_2,x_2,y_2)\in M\times (R\setminus\mathfrak{P})=k\times k^{*}\times k$, we have $$ \begin{aligned} (m_1,x_1,y_1)\sim (m_2,x_2,y_2) &\iff \exists (u,v)\in k^*\times k,(u,v)\cdot((x_1,y_1)\cdot m_2-(x_2,y_2)\cdot m_1)=0 \\ &\iff \exists u\in k^*, u(x_1m_2-x_2m_1)=0 \\ &\iff x_1m_2=x_2m_1 \end{aligned} $$ Therefore, the morphism $M_{\mathfrak{P}}\rightarrow k$ defined by $\frac{m}{(x,y)}\mapsto mx^{-1}$ is well defined and it is an isomorphism so that the $R_{\mathfrak{P}}$-module $M_{\mathfrak{P}}$ is isomorphic to the $k$-vector space $k$.
What you have written is absolutely correct. Here is a more general way of arguing it; let $R$ be a (commutative, unital) ring and $S\subset R$ a multiplicatively closed set, and let $R_S$ denote the localization of $R$ at $S$, with localization map $\lambda:R\to R_S$. Recall that there is a natural map $\mu:\operatorname{Ideals}(R)\to\operatorname{Ideals}(R_S)$ induced by localization; it takes an ideal $J\vartriangleleft R$ to the ideal of $R_S$ generated by $\lambda(J)\subset R_S$.
Fact: For any ideal $J\vartriangleleft R$, we have $\mu(J)\cong J_S$ as $R_S$-modules. $\blacksquare$
Now suppose the ideal $J$ contains an element $s\in S$; then necessarily $\mu(J)=R_S$, since $\mu(J)$ is an ideal containing the unit $\lambda(s)\in R_S^\times$. In particular, by the highlighted fact, $J_S$ is then a free $R_S$-module of rank $1$.
In your case, taking $R=k\times k$, $S=R\setminus\mathfrak{P}$, $M=k\times 0\vartriangleleft R$, and $s=(1,0)$ gives exactly the desired result.