Formatting a hard drive is a necessary process to "initialise it" and be able to use it for the first time as a user. So, no it is not affecting its lifespan. If formatting for the first time i suggest using a full format (not quick) so that the disk can detect and flag any bad sectors out.