The chain of events that led to a great-grandmother being fatally tasered by a police officer have been laid bare in court.