The woman had been having affairs with both men for more than four years and apparently refused to choose between them.
The agreement sets out a rota for Sylvester Mwendwa and Elijah Kimani to stay in her house and states they will both help raise any children she bears.
Mr Mwendwa told the BBC he loved the woman and said the contract would "set boundaries" and "keep the peace".
Lawyers said the "marriage" would only  be recognised if they could prove polyandry - a woman having more than one husband - was part of their custom.
The BBC's David Okwembah in the capital, Nairobi, says polyandry is not practised by any community in Kenya.
People have reacted with shock to the "marriage", arguing that it is not acceptable in terms of their culture, religion or the law, he says.
Defending the "marriage", Mr Mwendwa told the BBC Focus on Africa programme that while he may acting in breach of the law, he had decided to enter into a contract with Mr Kimani to end their rivalry.
"It could have been very dangerous if the other man would have come to her house and caught me... So our agreement is good as it sets boundaries and helps us keep peace."
Community policing officer Adhalah Abdulrahman persuaded the two men to marry the woman after he saw them fighting over her in Mombasa county, the local Daily Nation newspaper reports.
"We have agreed that from today we will not threaten or have jealous feelings because of our wife, who says she's not ready to let go of any of us," the agreement says, Kenya's NTV station reports.
"Each one will respect the day set aside for him. We agree to love each other and live peacefully. No-one has forced us to make this agreement," it adds.
Mr Mwendwa said her parents had given their blessing, while he is planning to pay the bride price.
The woman, a widow with two children, did not want to be named.
Mr Mwendwa told the BBC he did not marry the woman simply to satisfy his sexual desires but because he loved her and, most of all, her children.
"I have never been called a dad and her two children call me daddy," he said.
He said he hoped to have his own children with the woman, but she would have to decide.
"She is like the central referee. She can say whether she wants me or my colleague," he added.
Kenyan family lawyer Judy Thongori told the Daily Nation that the law does not explicitly forbid polyandry.
"The laws we have do not talk about it but for such a union to be recognised in Kenya, it has to be either under the statutory law or as customary marriage. The question we should ask now is whether these people come from communities that have been practising polyandry," she is quoted as saying.
Two Kenyan men have signed an agreement to "marry" the same woman.