Poland elected right-wing historian Karol Nawrocki, who won a narrow victory against Warsaw Mayor Rafal Trzaskowski.