Attain means (1) to achieve, (2) to accomplish, or (3) to reach the age of. Obtain means to get. There is sometimes common ground between these verbs, especially when somebody obtains something that is closely related to something that is often attained. For example, nuclear technology is something to be attained, while an actual nuclear weapon can only be obtained.
Examples
In fact, we have been able to attain a commendable level of economic success despite failing urban infrastructure and services. [Wall Street Journal]
The FBI director said that sometimes the best opportunity to obtain statements from a suspect is immediately following the arrest. [Christian Science Monitor]
When asked if it is now harder or easier to attain “the American Dream” than it was for their parents’ generation, 60 percent of Xavier’s 1,022 respondents said it’s getting harder. [The Atlantic]
Penn told the Tulsa World the charity allows ranchers to obtain hay and grain at participating feed stores. [The Republic]