When I turn the key I get a ticking sound sometimes. on 1998 Isuzu Rodeo

I turn the key and get a ticking sound but then turn the key again and it will start! And once it is started the brake and battery light will flicker!

2 answers
Have the battery cable connections checked and serviced as needed along with starter and alternator testing.
seek diag from a good mechanic