How did the first battle come to take place at Shiloh Battlefield?

First major battle in the West, that is.

Fairly simple situation. Grant was unaware of any Confederate troops in the area, and had told his men to rest easy by the Tennessee river (Pittsburg Landing).

The Confederates under the highly-respected Sidney Johnston caught them napping, and launched an attack that would have overwhelmed them, had it been continued. Johnston was killed, his second-in-command Beauregard called a halt for the night. By morning, Grant's troops had rallied, helped by reinforcements from the East.