Electronically driven phonon anomalies in transition metal carbides