The process you are referring to is called beta decay, specifically beta-minus decay. In beta decay, a neutron can be converted into a proton, an electron (also called a beta particle), and an antineutrino. This phenomenon is governed by the weak nuclear force, one of the fundamental forces in nature.
While it is true that a neutron is not composed of protons and electrons in the same way that, for example, a water molecule is made up of hydrogen and oxygen atoms, the internal structure of particles is more complex. Neutrons and protons are both composed of smaller particles called quarks, which are elementary particles that come in different types or "flavors" (up, down, charm, strange, top, and bottom).
A neutron is composed of two down quarks and one up quark (udd), while a proton consists of two up quarks and one down quark (uud). During beta-minus decay, one of the down quarks in the neutron undergoes a transformation into an up quark, converting the neutron into a proton. At the same time, an electron and an antineutrino are emitted.
The weak nuclear force mediates this process by changing the quark composition of the particles involved, and it also allows for the conversion of a down quark into an up quark through a W- boson exchange.
It's important to note that the conversion of a neutron into a proton and an electron does not involve the direct transformation of one particle into another particle. Instead, it is a result of changes in the quark composition and the emission of other particles during the decay process.