What is the mechanism behind the wave - particle duality I'm not exactly sure how to phrase this question; I've been reading about wave -particle duality, its history and how it works. But it's really bothering me, whenever I watch YouTube videos about it or read about it, physicists seems to be careful to say that a wave such as light can BEHAVE like a particle but never at the same time.
What I am wondering is, whether light is a wave that only behaves like a particle at times or an actual particle. Or is an electron a particle that behaves like a wave at times or can it be an actual wave?
And also what is the actual mechanism behind it because I can't seem to find the answer or is it simply that no one knows?
There does seem to be one explanation, but I'm not sure if it's correct or that I understood it right. It states that a wave is continuous and infinite but when several waves are joined, they can form a pulse and that is a particle.
I studied maths at college level, computer science at university level and physics only in high school (UK education, for US college=high school and high school=secondary education). But I keep up with physics as a hobby, I'm quite familiar with classical Newtonian physics and know some amount of general and special relativity. I'm really only just getting into the quantum world but this is one of the first things that struck me.
 A: The Trouble with Models
An honest answer is that we use models to simulate how the universe behaves, and sometimes our models just do not accurately display what something is. This is why there have been, are, and will be so many models in physics. Our models fail every so often. We try to keep the best models by updating and replacing as needed.
Light can behave as if it were a wave or as a particle, but it does not display behavior that only one model can totally explain. This is why the idea of the duality has been taken up. Both models are viewed as "equally correct," so both are applied. The most accurate way to describe light is that it acts like light, but that is not helpful.
In quantum mechanics, particles' behavior can be described by their wave functions. As the name implies, these functions often look more like waves rather than anything else. It turns out that these wave functions allow for particles to act as if they were a wave. On top of that, the situations where it acts like a wave is inexplicable if we think of electrons as hard particles. You can see this with phenomena like electron diffraction. In such cases, it is better to think of these electrons as waves.
Due to the fact that they exhibit so many wave-like and particle-like properties, we do not call them one or the other because the individual models do not account for the behavior we see well enough. Once again, our models are the sources of the confusion, and we are stuck with something that we apply two models to. We compromise and call it a duality; the electron is an electron, and we model it like a wave or a particle.
The Simple Answer
The simplest answer is that we do not really know what these things are.$^1$ We have nothing on our scale or within our experience that we can compare them to. Therefore, we use models of things we do know and carefully apply them. The particle-wave duality of these things is a by-product of the models we use to understand them.

Footnote

*

*When I say "we don't know what they are" I really mean "we don't know what one thing to compare them to as to understand everything about that." We do know many of the properties of light/electrons/etc, and we can predict their behavior with amazing accuracy.

A: 
What I am wondering is, is light a wave that only behaves like a particle at times or is it an actual particle. Or is an electron a particle that behaves like a wave at times or can it be an actual wave.

The first framework modeled with mathematics is what we now call the classical framework. This by the end of the nineteenth century had elegant theoretical models for mechanics,  electrodynamics, hydrodynamics and thermodynamics, to the point that some thought that physics theory was complete and only engineers would be using it to apply it.
In this classical framework a particle is defined/described  as a mass which can be described by its center of mass in space at (x,y,z) and its motion can be described with Newtonian mechanics.
Waves emerged as a fit to observations of waves in water, sound waves, and electromagnetic waves and widely described by wave equations which described a transport of energy and momentum on a continuum like water , or air, or pressure waves in solids. The solutions of the wave equations were sinusoidal functions. In analogy with sound waves electromagnetic waves were expected to be transport of energy and momentum on a medium, and that was why the luminiferous ether was postulated, as classical physics needed a medium for the transport of energy and momentum.
End of the nineteenth century  beginning of the twentieth a number of experimental observations showed gross divergences from the classical framework. The Michelson Morley experiment showed that light waves moved in vacuum, no ether was necessary, i.e. energy and matter were transported in space without an intervening medium.
The strongest discrepancies started with the observations of the quantization of light, with the black body radiation, with the photoelectric effect, and the spectra of atoms. Quantum mechanics developed for the level of atoms,  The Bohr model tried to keep the classical picture of particles, electrons orbiting a nucleus, with ad hoc postulates. It could not be turned into a general theory.
The solutions of the Schrodinger equation fitted the spectra of the atoms and were able to predict experimental observations in a self consistent  mathematical theory with a few postulates. The Schrodinger equation is a wave equation, except  that the interpretation  is not of a wave transporting energy and momentum, the postulate is that the square of the wavefunction gives the probability of finding the "particle" at (x,y,z). 
Light is an emergent property of zillions of photons. A photon displays its particle phase by the hit on the screen, and the wave property by the interference pattern when a lot of photons fall on the screen. The same is true for the electrons in the double slit experiment, falling one by one. 


electron build up over time

The spot is the particle nature. The statistical accumulation is the probability distribution described by a solution of the Schrodinger equation with the boundary conditions of the experiment. It is a probability wave, not a matter wave.
A: A quantum particle (entity) resists description in macroscopic, classical terms.
If we attempt to detect the presence of a quantum particle, we find that it interacts with our detector at (more or less) a point in space; it was detected here and not anywhere else (certainly not two or more places at once).  This is the particle-like nature.
On the other hand, quantum particles can exhibit the property of interference which suggests that there is also a wave-like nature.
So, whatever a quantum particle is possesses particle-like and wave-like properties but is neither a particle or wave.
Now, keep in mind that detection is interaction.  We can only detect a quantum particle by interacting with it in some way and this interaction generally leaves the particle in a different state after the interaction than before.
So, while can detect, e.g., an electron at a point with a particle detector, it isn't meaningful to picture the electron as a point particle in that location just before the detection.
We can say that the (previously undetected) electron interacted with our detection apparatus at that point, exhibiting the particle-like nature, but in general, there is a non-zero probability that it could have interacted elsewhere in our detector which is decidedly non-particle-like behaviour.

And also what is the actual mechanism behind it because I can't seem
  to find the answer or is it simply that no one knows?

It's not clear what you mean by mechanism but I think it likely that the best answer is no one knows.  We can mathematically model these quantum entities with wave function(al)s obeying wave equations, quantum fields obeying wave equations, etc., and test the predictions of these models against experiment.
However, the ontology of these mathematical objects (what is the ontological status of the wave function?) is unclear (see Interpretations of quantum mechanics).

It states that a wave is continues and infinite but when several waves
  a joined they can form a pulse and that is a particle.

It's true that a localized pulse can be decomposed into the sum (integral) of an infinity of non-localized waves.  However, as I've alluded to above, the ontological status of these waves is unclear.
A: The trick to wave/particle duality is that the phrasing "light IS a wave" or "light IS a particle" is misleading.  Light BEHAVES as a wave, or Light BEHAVES as a particle, depending on circumstances.
Wave/Particle duality is a construct that appears when we try to model subatomic things like electrons and photons.  As best as we understand, everything is described using a Quantum Mechanics "waveform."  Note, this quantum waveform is not the same thing as what you are calling a "wave," but unfortunately it has a very similar name.  QM waveforms are basically functions that obey wave mechanics, so they are given that name.  It confuses the issue, but I'll make sure to always use "waveform" when talking about the underlying QM waveform, and "wave" to talk about the wave part of wave/particle duality.
Given that we have no better model, I will talk as though QM defines the "true" nature of a photon or electron.  In reality, QM is just another model.  However, it is easier to explain if I get to pretend for a moment that it is the actual final answer to how the universe works.  The wording is much easier to read that way.
The real rub with this model is that its a real bugger to actually solve the equations for anything complicated.  The standard procedure is to break this waveform up into so-called "wave packets" which are little snippits of a waveform.  In the vast majority of cases, these snippets line up well enough to let us simplify our quantum models into more classical models of waves and particles:


*

*In many cases, the interactions at work affect all of the wave packets the same.  This leads to wave behavior, where we can use tools like superposition to model each piece independently then stitch them all together.

*In other cases, the interactions affect the wave packets markedly differently.  For instance, this happens in situations where there are interactions between photons and electrons.  Not all of the wave packets are affected the same way (some may interact with an electron, while a nearby packet coasts by with minimal interaction), so we can't use superposition.  However, if enough of these events occur, we lose all coherency of phase (an important factor in wave mechanics).  Accordingly, we can simplify to the particle model, rather than the wave model.  In the particle model, we assume all waveform phase issues are randomized because there have been enough interactions to break up any coherency.


Both of these rely on simplifications.  The wave model assumes that all packets are affected identically.  In reality, there are minor differences in interactions, but we assume they don't matter.  Likewise, the particle model assumes all packets are not coherent with each other, so we don't have to track phase.  We can model objects like billiard balls instead.  In reality, its rare for all of the particles to have no phase correlations, but we assume those tiny correlations don't matter much.
The trick to wave/particle duality is that, no matter which model we used, under the hood you really have a quantum waveform.  Its just a matter of which classical model is better at describing the situation with the fewest calculations possible.  Generally speaking, the vast majority of systems can be modeled as waves or particles, without any worry of duality.
But there are a few cases where it does matter.  It is possible to construct systems where the wave packets we broke the waveform into don't quite lose coherency, but don't quite get affected by the environment in the same way.  In these systems, we say the particle is exhibiting wave/particle duality, but in reality a better phrasing might be that neither simplification of the quantum model is sufficient to properly model the behavior.
The classic example is the single-photon dual slit experiment.  A single photon is fired towards two slits, so it clearly has to go through one of them towards a detector surface.  However, when we record the result of many such single-photon experiments and plot them together, it appears that the photon has somehow interacted with itself to form interference patterns, which could only occur if it went through both slits at once like a wave does.  The reality underneath is that the experiment manipulated a quantum waveform in a way which made it hard to model as either wave or particle.  The initial photon generation step is best modeled with the photon as a particle because there is a minimum quantum of energy associated with that photon (see the Photoelectric Effect).  However, in the second step (the slits), the photon is best modeled as a wave because the phase effects matter greatly.
What this wave/particle duality shows is that in a double-slit experiment, we see that light behaves neither perfectly like a wave nor perfectly like a particle.  The reconciliation of this is found in the quantum waveform, which when fully computed yields the experimentally achieved results.
A: A Possible Macroscopic Analog for the Wave-Particle Duality
The answer entitled "The Trouble with Models" give a good explanation regarding the limitations of our current models. However, I just came across a possible macroscopic analog (link provided in the references) which could help explain the wave particle duality. It involves suspending small droplets on a vibrating fluid bath. The idea proposed with this analogy is that quantum particles could be a coupling of both a particle and a wave.
References:
http://math.mit.edu/~bush/?p=582 (this is the video link; you can see the articles by going up a level)
A: The stage in science where this conflict arises marks the dawn of a new mechanism to understand and thereby attend to some questions that have remained unanswered since the last thousands of years before humanity.
The hint lies not in the particle or the wave. Infact we need to look deeper, into things that are still more subtler! Here science declares these to be subtlest. So, we must look for new ways to make inroads; new concepts, new theories, and a fresh new approach. But this is not easy. This paradigm shift will take its own time and generations will suffer, in ignorance.
