Hartlepool is to benefit from an almost £6 million investment in flood defences to help ensure homes and businesses are better protected.