Context: The eROSITA X-ray telescope onboard the Spectrum-Roentgen-Gamma (SRG) satellite has started to observe new X-ray sources over the full sky at an unprecedented rate. Understanding the selection function of the source detection is important to the subsequent scientific analysis of the eROSITA catalogs. Aims: Through simulations, we test and optimize the eROSITA source detection procedures, and characterize the detected catalog quantitatively. Methods: Taking the eROSITA Final Equatorial-Depth Survey (eFEDS) as an example, we run extensive photon event simulations using our best knowledge of the instrument characteristics, the background spectrum, and the population of astronomical X-ray sources. We analyze the source detection results based on the origin of each photon. Results. The source detection procedure is optimized according to the source detection efficiency. We choose a two-pronged strategy to build the eFEDS X-ray catalogs, creating a main catalog using only the most sensitive band (0.2-2.3 keV) and an independent hard-band selected catalog using multi-band detection in a range up to 5 keV. From the mock catalogs (available with this paper), we measure the catalog completeness and purity, which can be used in both choosing the sample selection thresholds and in further studies of AGN and cluster demography.