Does it summon skeletons from dead troops or does it summon them from nowhere? When does a witch attack and when does it summon?
No, she does not summon Skeletons out of thin air. When she summons them, it appears that they come out of the ground in a certain radius of the Witch. The Witch summons every 6 seconds and so on until she summons the max amount of Skeletons, which is 6 for Level 1 Witch and 8 for Level 2 Witch. She attacks every 0.7 seconds with a range of four tiles. My source and more information can be found at the Clash of Clans Wiki. Summoning from the ground (any ground/land) is just a coll feature to make the summoning of Skeletons to be more realistic and might scare people just for fun. There is no special effect from the summoning other than the Skeletons. There doesn't need to be any past corpses. She will continue to spawn Skeletons, if you have any killed troops or not.
From the moment she is deployed, the witch summon 3 skeletons at level 1 each 6 seconds with a max of 6 skeletons. At level 2 she summons 4 skeletons each 6 seconds with a max of 8 skeletons.
Skeletons are summoned anytime anywhere out of the ground.
She attacks by herself when she comes near a building or enemy troops. But she is weak so don't expect too much from her.
The witch will use her ranged attack as long as she is not in her summoning animation for the skeletons.
I looked for the exact frequency at which witches spawn skeletons but I found numerous answers places.
The witch by herself is has very low HP and low attack damage. Same goes for her skeletons. Witches are often used for distraction troops but some skilled players can use a large amount of witches to do a lot of damage to a base.