Stars form in high-density regions in molecular clouds, which are known to be filamentary. The formation and evolution of filaments are important because they determine the initial conditions for star formation. In this presentation, I will report our results on simulations of filament formation and evolution. It is known that shock waves passing through molecular clouds induce the formation of filaments. However, the mechanism of filament formation has not been well understood due to confusion created by competing theories. In this study, we performed three-dimensional magnetohydrodynamic simulations that mimic the interaction between shock waves and molecular clouds for a wide range of parameters, and identified the filament formation mechanism for each parameter. As a result, we found that the filament formation mechanism changes depending on the velocity of the shock wave, and succeeded in obtaining a unified understanding of the formation mechanism. Furthermore, we measured the line density of the formed filaments and found that the initial conditions for massive star formation can be naturally realized in filament formation driven by fast shock waves ($\gtrsim 5 km/s$). Filaments evolve through gas flows along magnetic fields. The filament width is an important quantity that can determine the initial conditions for star formation and the mass of the star, and the width is thought to be determined during the evolution process. Observations have shown that the filament width is 0.1 pc, independent of the line density. Theoretically, however, the denser the filament is, the smaller the width should be, which contradicts the observations. Filament boundaries are often considered to be "slow shocks". The wavefront of a slow shock is unstable and is expected to provide kinetic energy to drive turbulence in the filament and delay gravitational contraction. Also, bipolar diffusion works at the filament scale, so this should be taken into account. In this study, we aim to explain the universality of the filament width, and first investigate whether slow shock instability with bipolar diffusion can generate turbulence using non-ideal MHD simulations. As a result of the nonlinear evolution of the slow shock instability with bipolar diffusion, we found a turbulence driving mechanism that increases the width of massive filaments.