That's never been spelled out. Joanie hadn't turned two when Noah was imprisoned. Sometime after that, while still living in Manhattan, Alison told Cole that Joanie was Cole's daughter, and the exes shared custody while also working together on the Lobster Roll.
Six months before season 3 begins, Alison had her breakdown: Joanie had just turned four -- the same age as Gabriel when he died -- then became ill and didn't seem able to get well. Spiraling, terrified of her incapacity as a mother, Alison left Joanie with Cole and Luisa on yet another stormy night in Montauk, and disappeared (to seek in-patient care for her PTSD, anxiety and depression).
At the beginning of season 3, a recovering Alison leaves the facility and NYC: she moves to Montauk, taking an apartment there and furnishing Joanie's room with Gabriel's toychest and a dollhouse that Alison builds for her. Cole and Luisa aren't having it, at first, but though they sue for sole custody, Luisa eventually relents and even helps Alison regain physical custody. Luisa is guided in part by how much Joanie not only adores Alison, but trusts her.
Noah comes to see Alison in Montauk mid-season (after attacking himself in his kitchen, the night he argued with his student Audrey about Descent and his/his avatar's treatment of Alison/her avatar). He negotiates another day with her on Block Island, in exchange for signing the divorce papers she's sent him. They end up missing the last ferry and spend the night speaking of their childhoods. How Alison's greatest fear is to emotionally and physically abandon Joanie as her mother did her. How Noah's worst impulse is to flee women he loves, to cut himself free of their pain, as he did with his mother. When they return to Montauk, he signs the papers, leaves with good grace, then hallucinates being driven off the road by the guard.
What did Alison tell Joanie? Something like, "Your father and I weren't together when I was pregnant with you, and that's when I married Noah. He helped me take care of you when you were a baby. But he had to go away, and I wanted you and your father to have each other. So your father and Luisa and I figured it out. And Noah moved to California to be near his own kids, so here we are..." With questions answered only if asked : "He went to jail for something he didn't do" and "I don't know; but when people are unhappy, sometimes that's why they do things. To really feel it."