So I am not Irish but I find it odd how de Valera became President after his side lost the Irish Civil War. To me it seems like the equivalent of Jeff Davis becoming President of the United States a few years after the end of the American Civil War. I would be grateful of someone who knows more about Irish history could explain it.
There are two important things to remember here: First, that before he was president, De Valera was Taoiseach - the prime minister - the current constitution of Ireland, Bunreacht na hEireann, was drafted by De Valera and his government. His election to the presidency came after his political career as leader of the Irish government. I suppose that probably just retools your question to "How did he become leader of the Irish government despite losing a civil war?"
The second thing to remember that the Irish Civil War was instigated by the split in the Irish national liberation movement over the Anglo-Irish Treaty, a peace agreement with the British Empire which would establish the Irish Free State and end the War of Independence (in the South of the island, anyways). After the Empire threatened war, the Treaty was debated in the Dáil (Irish parliament) and narrowly passed with a vote of 64-57, with 4 abstentions/non votes. The Irish Republican Army split down the middle on the issue, with a slim majority opposing the Treaty entirely and refusing to accept it.
The Civil War was brutal, with the Free State committing war crimes such as tying prisoners to land mines and blowing them up, banning swathes of political opposition and generally crushing opposition to the Treaty by military force. The Republican (i.e. anti-Treaty) movement was defeated militarily - it was not necessarily defeated in terms of popular opinion.
So, how did Dev come to power? Anti-Treaty Sinn Féin, which De Valera was a leading figure of at the time, refused to acknowledge the legitimacy of the Free State parliament as it contained an Oath of Allegiance to the British monarchy - they would stand for election and if they got elected, refused to take their seats in a policy called abstentionism. This mirrored the policy of Sinn Féin under British rule, hoping to build up sufficient support to declare their own parliamentary body.
Sinn Féin won 27% of the vote in the 1923 election (immediately after the Civil War) on an abstentionist platform. Abstentionism was not unpopular, but it also was not getting the Republican movement anywhere, and they were no further from or closer to winning the Republic in 1923 than they were in 1926 when De Valera concluded that abstentionism was a dead end strategy and led a split to form Fianna Fáil. Just a year later, on the back of its economic-nationalist, Christian-democratic and Irish Republican politics, it secured 35% of the vote in the 1927 general election (now the second largest party), taking effectively all of Sinn Féin's vote share and knocking them out of electoral politics entirely.
This laid the groundwork for the 1932 General Election where De Valera and Fianna Fáil would come to power. The Great Depression was in full swing and had its own significant impact on Ireland - Fianna Fáil won the election predominantly on back of farmers (attracted by De Valera's protectionism), and the rural and urban poor.
One factor in the background of the election was the Land Annuities campaign. Britain was still charging Irish farmers for the loans they had to take to purchase their land back from English landlords. The Cumann na nGaedheal government promised to continue paying these effectively colonial debts. A communist and Republican, Peadar O Donnell, had used the Republican newspaper An Phoblacht to build a mass campaign against land annuities - Fianna Fáil adopted the ending of annuities payments as part of its election promises (and it followed through, causing a trade war with Britain that lasted until 1938).
Fianna Fáil would go on to rule Ireland for most of the 20th century, part of which was De Valera getting elected to the presidency (a ceremonial and mostly powerless position) in 1959.