As usual, many different factors come into play.
The Halifax and Manchester came into production at around the same time. Manchester = disaster, Halifax = OK at the time. Then the Lancaster is developed from the Manchester and..it's ( probably

) better than the Halifax. But then, Handley Page and their subsidiary factories are 'tooled up' for the Hali and to convert to Lancaster production would take months. Meanwhile, Avro and
their subsidiaries can only produce so many Lancasters, during which time the Halifaxes fill the gap....
Of course, if the Air Ministry knew for absolutely certain which would be the better aircraft straight from the drawing-board...but somehow, it never seems to happen that way !
( I shall now hide under my computer desk waiting for Ta152 to come at me with guns blazing to defend the Halifax !

)