At least two children and five suspected militants have died after a car bomb accidentally exploded in northwest Pakistan.