Read Chapter 3 of Suddenly Tomorrow Came... A History of the Johnson Space Center
Basically it can be because the Air Force decided not to close the preferred site, MacDill Air Force Base, and therefore Houston moved from second place to the preferred site.
Or it could've been because "...Texas undoubtedly exerted an enormous
political influence on such a decision. Lyndon B. Johnson was Vice President and head of the Space Council, Albert Thomas headed the House Appropriations Committee, Bob Casey and Olin E. Teague were members of the House Committee on Science and Astronautics, and Teague headed the Subcommittee on Manned Space Flight. Finally, Sam Rayburn was Speaker of the House of Representatives."
If you want to know how Cape Canaveral evolved from a missle range into a SpacePort see The History of Cape Canaveral page.