Latvia joined both NATO and the EU in the spring of 2004 .