This is intentional. Mobs despawn if they are further than 128 blocks from a player. When you are in spectator mode, you should not count as a player otherwise you could influence the world. Since you are not a player, their is no player within 128 blocks so it despawns. If you name the mob and then go into spectator mode, you may notice that the mob loses all ai, this is also to do with there being no player within range.
This is intentional. Mobs despawn if they are further than 128 blocks from a player. When you are in spectator mode, you should not count as a player otherwise you could influence the world. Since you are not a player, their is no player within 128 blocks so it despawns. If you name the mob and then go into spectator mode, you may notice that the mob loses all ai, this is also to do with there being no player within range.