We report on a 2D kinetic Monte Carlo model that describes the resistive switching in electrochemical metallization cells. To simulate the switching process, we consider several different processes on the atomic scale: electron-transfer reactions at the boundaries, ion migration, adsorption/desorption from/to interfaces, surface diffusion and nucleation. These processes result in a growth/dissolution of a metallic filament within an insulating matrix. In addition, the model includes electron tunneling between the growing filament and the counter electrode, which allows for simulating multilevel switching. It is shown that the simulation model can reproduce the reported switching kinetics, switching variability and multilevel capabilities of ECM devices. As a major result, the influence of mechanical stress working on the host matrix due to the filamentary growth is investigated. It is demonstrated that the size and shape of the filament depend on the Young's modulus of the insulating matrix. For high values a wire-like structure evolves, whereas the shape is dendritic if the Young's modulus is negligible.