2004 sportsman 400

I have a 400 sporstman 2004 when driving it sometimes it will cut off just like the key was turned off after it stops rolling I can turn key and it will start right up and run fine for days now when I trailered it home it will not start the speedometer is blank like there’s no battery it………any ever had this problem?