Castleford withstood a much-improved Hull FC display to secure a 26-18 victory in the second round of the 2019 Super League season.