Let us discuss this in a number of steps:
Exercise 1: Let $A$ be a commutative ring and let $M$ be an $A$-module. Let $\text{MaxSpec}(A)$ be the set of all maximal ideals of $A$. Prove that the natural $A$-module homomorphism $\phi:M\to \bigoplus_{m\in\text{MaxSpec}(A)} M_m$ is injective. (Hint: if $x\in M$, choose a maximal ideal $m$ of $A$ such that $\text{Ann}(x)=\{a\in A:ax=0\}\subseteq m$. Consider the image of $x$ in $M_m$.)
Exercise 2: Let us consider the $\mathbb{Z}$-module $\mathbb{Z}$ and let $\phi:\mathbb{Z}\to \bigoplus_{m\in\text{MaxSpec}(\mathbb{Z})} \mathbb{Z}_m$ be the natural $\mathbb{Z}$-module homomorphism. Prove that $\phi$ is not surjective. (Hint: let us order the positive prime numbers in the manner $p_1,p_2,\dots$. If $n\in \mathbb{Z}$, let us remark that the image of $n$ in $\mathbb{Z}_{p_i}$ is $\frac{n}{1}$. Prove that the element $(1,0,0,\dots)\in \bigoplus_{i=1}^{\infty} \mathbb{Z}_{p_i}$ has no preimage in $\mathbb{Z}$ under $\phi$. If you are stuck, think about the kernel of the localization homomorphism $\mathbb{Z}\to \mathbb{Z}_{p_i}$ for $i\in\mathbb{N}$.)
Problem 1: Let $A$ be an integral domain. Prove that the natural $A$-module homomorphism $\phi:A\to \bigoplus_{m\in\text{MaxSpec}(A)} A_m$ is not surjective unless $A$ is a local domain. Can you generalize to other commutative rings?
Problem 2: Let $A$ be an integral domain. Prove that $A=\bigcap_{m\in\text{MaxSpec}(A)} A_m$.
I hope this helps!