Work statistics, irreversible heat and correlations build-up in joining two spin chains