A Latvian republic emerged following World War I , but it was annexed by the USSR in 1940 - an action never recognized by the US and many other countries .