The UK Government has recognised Wales has been “hard done by” and will provide new funding for rail, the Welsh First Minister said.