You purchase them from other players and/or factions. You have to contact them to make a deal. Most players use the off-site CenterPoint Market (http://market.centrepointstation.com/) to conduct deals, though people do also use the Commmerce thread in these forums (RPG Center at the top section).
For factions, visit the ship manufacturers and they will usually have a list of prices for their ships. Be aware though that not all those factions sell to the public.