Posey's homer leads Giants to 4-2 win over Mets