I have created a new Search managed service, and I define the search source to be
http://hostname:portnumber. But SharePoint 2013 automatically created a new content source named “Local SharePoint sites”so why did SP created this search source? And when/why it created this?
When you provisioned the Search Service Application SharePoint created the Local SharePoint Sites content source for you and added start addresses for existing Web Applications. As you create new web applications SharePoint will add those to the Local SharePoint Sites content source.