in 1519 and onwards, when the Spanish saw the massive death toll due to diseases, did they think they were the cause of them? and when did the Europeans realize it was them who were bringing the diseases to the new world?
They realised they were the transmitters of the smallpox and other sicknesses within a few decades. The Spaniards eventually realised this, but were entirely unaware of the transmission mechanism of these diseases or plagues. The author that best describes this is Francisco López de Gómara (more appropriately Francisco López, de Gómara). I translate:
These friars took the Indians from the courtiers and absentees, because their servants mistreated them, and reduced them to villages in order to better instruct them, but it was damaging to them to come to villages with Spaniards, for they gave them smallpoxes, a sickness new to them and that killed them in infinite numbers.
Francisco López writes in very late dates, but that does not mean he would have been the first to spot this, the observation was rather general, and can be found in other authors like fray Toribio de Benavente, more commonly known as Motolinía:
God punished and hurt this land and those that were there, both natural and foreigners, with ten terrible plagues.
The first one was the smallpox, and it started in this manner. Being Hernán Cortés captain and governor, at the time that captain Pánfilo de Narváez came ashore on this land, in one of his ships came a black man hurt of the smallpox, a sickness that had never been seen in these lands
This is not only correct for the context of the continental America, but for the insular America too: friar Bartolomé de las Casas and others mention the devastating impact of the smallpox on the Indian populations, and the fact that it must have come from Spain:
More happened on this island around the year eighteen and nineteen. And it happened, by God's will or permission, in order to set free of their many sufferings, mostly in the mines, the very few Indians that still lived, and as a punishiment to those who oppressed them so they would feel how much they needed the Indians, came a terrible plague that nearly all died and very few remained alive. This was the smallpox that struck the Indians, that some person brought from Castille.
On the other hand, they became aware of the diseases that went the other way around, like syphilis and the parasite known as niguas, which is some sort of lice that carves its way into your skin causing terrible itches. The death toll was completely asymmetric due to the different nature of the diseases: syphilis is an STD, while the smallpox is transmitted through breath and the aerosols and droplets coming from the mouth. The immunity developed by humans is a curious thing: smallpox was terrible but did not have a tremendous death toll amongst the Spanish settlers but killed the natives like flies; syphilis apparently did not cause that many problems to the Indians whereas the effects on the Spaniards were devastating.
The fact that the smallpox was brough by the Spaniards was common knowledge, as accredited by the Relación de Michoacán, written by fray Jerónimo de Alcalá in 1539-1541:
All the Spaniards say it unanimously, those from that time, and this sickness was general in the whole of New Spain, and hence credence should be given to them in what they say about the measles and the smallpox. They say they had never had those sicknesses and that the Spanish brought them to that land.
At the moment of contact, they may not have been aware of the fact that they brought the smallpox, measles, and the flu, but soon they figured out that they must have been the ones who brought these diseases with them which caused plagues of quite literally Biblical proportions.