No, they are not — despite the shared name and the obvious family resemblance.
Warhammer is a dark fantasy setting built on a roughly recognisable medieval world, while Warhammer 40,000 is far-future science fiction. They are separate universes with separate canons.
The confusion is understandable, because the two borrow from each other constantly. Both run on the same tabletop rules DNA, both are obsessed with grim, oversized factions, and there are races and background elements that clearly rhyme — an orc in one is recognisably cousin to an Ork in the other. Games Workshop has occasionally played with the idea of a connection, but nothing in either setting's official canon treats them as one continuous universe.