We consider a superconducting nanowire proximity coupled to a superconductor/ferromagnet/superconductor (S/F/S) junction, where the magnetization penetrates into a superconducting segment in a nanowire decaying as], where n is the site index and the ξ is the decay length. We tune chemical potential and spin-orbit coupling so that the topological superconducting regime hosting the Majorana fermion is realized for long ξ . We find that when ξ becomes shorter, zero energy state at the interface between a superconductor and a ferromagnet splits into two states at nonzero energy. Accordingly, the behavior of the Josephson current is drastically changed due to this "zero mode-nonzero mode crossover." By tuning the model parameters, we find an almost second-harmonic current-phase relation sin 2ϕ, where ϕ is the phase difference of the junction. Based on the analysis of Andreev bound state (ABS), we clarify that the current-phase relation is determined by coupling of the states within the energy gap. We find that the emergence of crossing points of ABS is a key ingredient to generate sin 2ϕ dependence in the current-phase relation. We further study both the energy and ϕ dependence of pair amplitudes in the ferromagnetic region. For large ξ , an odd-frequency spin-triplet s-wave component is dominant. The magnitude of the odd-frequency pair amplitude is enhanced at the energy level of ABS.