The processes vary from agency to agency. In general, data is gathered as part of a regular task for a project or program within an agency (this could be the Mars Program or the 2010 census). The data is structured, validated, and organized, and then that data is used for a purpose for the agency (anything from scientific analysis of the surface of Mars to a count of people in a specific city). The data is generally approved for release outside of the agency through a secondary process that ensures it is valid, understandable, and does not violate either citizen privacy or national security. It is then posted on an agency site.
Most agencies also release their data to Data.gov, which allows people to find the data independent of knowing the specific program, project, or web site to which the agency has released the data. The existing policies to which U.S. federal data must comply to be released are posted at: http://www.data.gov/data-policy
The new Executive Order and Open Data Policy http://www.whitehouse.gov/the-press-office/2013/05/09/executive-order-making-open-and-machine-readable-new-default-government- requires that agencies default to openly posting data gathered in the course of doing their work. This still allows an agency to not post data that would violate a citizen's privacy or national security, and it would also allow an agency the opportunity to post the data once it is structured, valid, organized, and understandable (pursuant to the Information Quality Act, P.L. 106-554).